diff --git a/fOBS.pas b/fOBS.pas index ca156eb..502232b 100644 --- a/fOBS.pas +++ b/fOBS.pas @@ -35,11 +35,11 @@ type procedure UpdateGridFromArray; procedure AddChat(newRecord: TOBSChat); - procedure EdtChat(newRecord: TOBSChat); + procedure EdtChat(newRecord: TOBSChat; oldPort: Integer); procedure DelChat(aPort: Integer); procedure AddNotify(newRecord: TOBSNotify); - procedure EdtNotify(newRecord: TOBSNotify); + procedure EdtNotify(newRecord: TOBSNotify; oldPort: Integer); procedure DelNotify(aPort: Integer); procedure AddKandinsky(newRecord: TOBSKandinsky); @@ -90,7 +90,7 @@ begin dport := strtoint(sgWebChats.Cells[0, i]) + 1; end; fCreateChat.sbWebServerPort.Value := dport; - fCreateChat.isEdit:=false; + fCreateChat.isEdit := false; fCreateChat.Show; end; @@ -122,7 +122,7 @@ begin dport := strtoint(sgWebChats.Cells[0, i]) + 1; end; fCreateNotify.sbWebServerPort.Value := dport; - fCreateNotify.isEdit:=false; + fCreateNotify.isEdit := false; fCreateNotify.Show; end; @@ -175,7 +175,7 @@ begin if listKandinsky[i].port = aPort then begin // Сдвигаем элементы массива - for j := i to High(listKandinsky) - 1 do + for j := i to High(listKandinsky) do listKandinsky[j] := listKandinsky[j + 1]; // Уменьшаем размер массива SetLength(listKandinsky, Length(listKandinsky) - 1); @@ -197,7 +197,7 @@ begin if listNotify[i].port = aPort then begin // Сдвигаем элементы массива - for j := i to High(listNotify) - 1 do + for j := i to High(listNotify) do listNotify[j] := listNotify[j + 1]; // Уменьшаем размер массива SetLength(listNotify, Length(listNotify) - 1); @@ -210,87 +210,66 @@ begin db.SaveRecordArray('listNotify', listNotify); end; -procedure TfrOBS.EdtChat(newRecord: TOBSChat); +procedure TfrOBS.EdtChat(newRecord: TOBSChat; oldPort: Integer); var - rChat: TOBSChat; - SavedColor: TAlphaColor; + i: Integer; begin - rChat:= newRecord; - - if TryStrToUInt('$' + rChat.ColorBlock, Cardinal(SavedColor)) then - fCreateChat.frChatSettings1.cpStyleBlockColor.Color := SavedColor - else - fCreateChat.frChatSettings1.cpStyleBlockColor.Color := TAlphaColorRec.Black; - fCreateChat.frChatSettings1.ccbStyleBorderColor.ItemIndex := - rChat.ColorBorder; - fCreateChat.frChatSettings1.ccbBColor.ItemIndex := rChat.ColorBackground; - fCreateChat.frChatSettings1.sbStyleBlockBorderSize.Value := rChat.SolidBorder; - fCreateChat.frChatSettings1.sbStyleBlockPadding.Value := rChat.Paddings; - - fCreateChat.frFontSettings1.ccbFontColor.ItemIndex := rChat.ColorFont; - fCreateChat.frFontSettings1.sbFontSize.Value := rChat.SizeFont; - fCreateChat.frFontSettings1.cbFontStyleDefault.ItemIndex := rChat.StyleFont; - - fCreateChat.sbTimeMsg.Value := rChat.TimeMess; - fCreateChat.sbMaxMsg.Value := rChat.MaxCountMess; - fCreateChat.sbWebServerPort.Value := rChat.port; - fCreateChat.Show; + for i := 0 to High(listChats) do + if listChats[i].port = oldPort then + begin + listChats[i] := newRecord; + UpdateGridFromArray; + db.SaveRecordArray('listChats', listChats); + Break; + end; end; -procedure TfrOBS.EdtNotify(newRecord: TOBSNotify); +procedure TfrOBS.EdtNotify(newRecord: TOBSNotify; oldPort: Integer); var - OBSNotify: TOBSNotify; - SavedColor: TAlphaColor; + i: Integer; begin - OBSNotify:=newRecord; - with OBSNotify do - begin - fCreateNotify.edtESImage.Text := Picture; - fCreateNotify.edtESSound.Text := Sound; - - if TryStrToUInt('$' + ColorBlock, Cardinal(SavedColor)) then - fCreateNotify.frColorSettings1.cpStyleBlockColor.Color := SavedColor - else - fCreateNotify.frColorSettings1.cpStyleBlockColor.Color := - TAlphaColorRec.Black; - - // fCreateNotify. ColorBlock:= GetColorFromColorPanel(frColorSettings1.cpStyleBlockColor.Color); - fCreateNotify.frColorSettings1.sbStyleBlockBorderSize.Value := SolidBorder; - fCreateNotify.frColorSettings1.sbStyleBlockPadding.Value := Paddings; - fCreateNotify.frColorSettings1.ccbStyleBorderColor.ItemIndex := ColorBorder; - fCreateNotify.frColorSettings1.ccbBColor.ItemIndex := ColorBackground; - - fCreateNotify.edtESTitle.Text := HeaderText; - fCreateNotify.frFontSettings2.ccbFontColor.ItemIndex := HeaderColorFont; - fCreateNotify.frFontSettings2.sbFontSize.Value := HeaderSizeFont; - fCreateNotify.frFontSettings2.cbFontStyleDefault.ItemIndex := - HeaderStyleFont; - - fCreateNotify.edtESMessage.Text := MessText; - fCreateNotify.frFontSettings3.ccbFontColor.ItemIndex := MessColorFont; - fCreateNotify.frFontSettings3.sbFontSize.Value := MessSizeFont; - fCreateNotify.frFontSettings3.cbFontStyleDefault.ItemIndex := MessStyleFont; - - fCreateNotify.sbTimeMsg.Value := TimeMess; - fCreateNotify.cbEventsType.ItemIndex := TypeEvent; - fCreateNotify.edtIF.Text := TypeEdit; - fCreateNotify.sbWebServerPort.Value := port; - end; + for i := 0 to High(listNotify) do + if listNotify[i].port = oldPort then + begin + listNotify[i] := newRecord; + UpdateGridFromArray; + db.SaveRecordArray('listNotify', listNotify); + Break; + end; end; procedure TfrOBS.sgWebChatsCellDblClick(const Column: TColumn; const Row: Integer); +var + myChatRec: TOBSChat; + myNotifyRec: TOBSNotify; + i: Integer; begin -if sgWebChats.Cells[1,row] = 'Оповещение' then - begin - fCreateNotify.isEdit:=true; - fCreateNotify.Show; - end; - if sgWebChats.Cells[1,row] = 'Чат' then - begin - fCreateChat.isEdit:=true; - fCreateChat.Show; - end; + if sgWebChats.Cells[1, Row] = 'Оповещение' then + begin + for i := 0 to High(listNotify) do + if listNotify[i].port = (strtoint(sgWebChats.Cells[0, Row])) then + begin + myNotifyRec := listNotify[i]; + Break; + end; + + fCreateNotify.isEdit := true; + fCreateNotify.setRecord(myNotifyRec); + fCreateNotify.Show; + end; + if sgWebChats.Cells[1, Row] = 'Чат' then + begin + for i := 0 to High(listChats) do + if listChats[i].port = (strtoint(sgWebChats.Cells[0, Row])) then + begin + myChatRec := listChats[i]; + Break; + end; + fCreateChat.isEdit := true; + fCreateChat.setRecord(myChatRec); + fCreateChat.Show; + end; end; procedure TfrOBS.UpdateGridFromArray; diff --git a/uCreateChat.fmx b/uCreateChat.fmx index d70c784..f01cd9d 100644 --- a/uCreateChat.fmx +++ b/uCreateChat.fmx @@ -138,7 +138,7 @@ object fCreateChat: TfCreateChat Size.Width = 112.000000000000000000 Size.Height = 19.000000000000000000 Size.PlatformDefault = False - TabOrder = 38 + TabOrder = 37 Text = #1042#1077#1095#1085#1086 end object sbWebServerPort: TSpinBox diff --git a/uCreateChat.pas b/uCreateChat.pas index 79befc8..dc28bf2 100644 --- a/uCreateChat.pas +++ b/uCreateChat.pas @@ -34,7 +34,9 @@ type function GetColorFromColorPanel(aColor: TAlphaColor): string; public { Public declarations } - isEdit:boolean; + isEdit: boolean; + oldPort: integer; + procedure setRecord(aRec: TOBSChat); end; var @@ -66,6 +68,28 @@ begin result := Format('rgba(%d, %d, %d, %.2f)', [r, G, B, A], FS); end; +procedure TfCreateChat.setRecord(aRec: TOBSChat); +var + SavedColor: TAlphaColor; +begin + if TryStrToUInt('$' + aRec.ColorBlock, Cardinal(SavedColor)) then + fCreateChat.frChatSettings1.cpStyleBlockColor.Color := SavedColor + else + fCreateChat.frChatSettings1.cpStyleBlockColor.Color := TAlphaColorRec.Black; + fCreateChat.frChatSettings1.ccbStyleBorderColor.ItemIndex := aRec.ColorBorder; + fCreateChat.frChatSettings1.ccbBColor.ItemIndex := aRec.ColorBackground; + fCreateChat.frChatSettings1.sbStyleBlockBorderSize.Value := aRec.SolidBorder; + fCreateChat.frChatSettings1.sbStyleBlockPadding.Value := aRec.Paddings; + + fCreateChat.frFontSettings1.ccbFontColor.ItemIndex := aRec.ColorFont; + fCreateChat.frFontSettings1.sbFontSize.Value := aRec.SizeFont; + fCreateChat.frFontSettings1.cbFontStyleDefault.ItemIndex := aRec.StyleFont; + + fCreateChat.sbTimeMsg.Value := aRec.TimeMess; + fCreateChat.sbMaxMsg.Value := aRec.MaxCountMess; + fCreateChat.sbWebServerPort.Value := aRec.port; +end; + procedure TfCreateChat.btnCreateWebChatClick(Sender: TObject); var OBSChat: TOBSChat; @@ -83,9 +107,12 @@ begin OBSChat.MaxCountMess := round(sbMaxMsg.Value); OBSChat.TimeMess := round(sbTimeMsg.Value); - OBSChat.Port := round(sbWebServerPort.Value); + OBSChat.port := round(sbWebServerPort.Value); - TTW_Bot.frOBS1.AddChat(OBSChat); + if isEdit then + TTW_Bot.frOBS1.EdtChat(OBSChat, oldPort) + else + TTW_Bot.frOBS1.AddChat(OBSChat); close; end; @@ -93,7 +120,7 @@ procedure TfCreateChat.FormCreate(Sender: TObject); procedure LoadFontList; var SearchRec: TSearchRec; - n: Integer; + n: integer; begin if not DirectoryExists(myConst.fontsPath) then CreateDir(myConst.fontsPath); @@ -117,7 +144,7 @@ procedure TfCreateChat.FormCreate(Sender: TObject); procedure LoadChatOBSSettings; var - I: Integer; + I: integer; c: TComponent; ColorStr: string; SavedColor: TAlphaColor; @@ -146,7 +173,7 @@ procedure TfCreateChat.FormCreate(Sender: TObject); end; begin -isEdit:=false; + isEdit := false; LoadChatOBSSettings; LoadFontList; @@ -154,10 +181,10 @@ end; procedure TfCreateChat.FormShow(Sender: TObject); begin -if isEdit then -btnCreateWebChat.Text:='Изменить чат' -else -btnCreateWebChat.Text:='Создать чат'; + if isEdit then + btnCreateWebChat.text := 'Изменить чат' + else + btnCreateWebChat.text := 'Создать чат'; end; end. diff --git a/uCreateNotify.pas b/uCreateNotify.pas index 5b2d0c3..6077c98 100644 --- a/uCreateNotify.pas +++ b/uCreateNotify.pas @@ -44,6 +44,8 @@ type public { Public declarations } isEdit: boolean; + oldPort: integer; + procedure setRecord(aRec: TOBSNotify); end; var @@ -75,6 +77,44 @@ begin result := Format('rgba(%d, %d, %d, %.2f)', [r, G, B, A], FS); end; +procedure TfCreateNotify.setRecord(aRec: TOBSNotify); +var + SavedColor: TAlphaColor; +begin + with aRec do + begin + fCreateNotify.edtESImage.Text := Picture; + fCreateNotify.edtESSound.Text := Sound; + + if TryStrToUInt('$' + ColorBlock, Cardinal(SavedColor)) then + fCreateNotify.frColorSettings1.cpStyleBlockColor.Color := SavedColor + else + fCreateNotify.frColorSettings1.cpStyleBlockColor.Color := + TAlphaColorRec.Black; + + fCreateNotify.frColorSettings1.sbStyleBlockBorderSize.Value := SolidBorder; + fCreateNotify.frColorSettings1.sbStyleBlockPadding.Value := Paddings; + fCreateNotify.frColorSettings1.ccbStyleBorderColor.ItemIndex := ColorBorder; + fCreateNotify.frColorSettings1.ccbBColor.ItemIndex := ColorBackground; + + fCreateNotify.edtESTitle.Text := HeaderText; + fCreateNotify.frFontSettings2.ccbFontColor.ItemIndex := HeaderColorFont; + fCreateNotify.frFontSettings2.sbFontSize.Value := HeaderSizeFont; + fCreateNotify.frFontSettings2.cbFontStyleDefault.ItemIndex := + HeaderStyleFont; + + fCreateNotify.edtESMessage.Text := MessText; + fCreateNotify.frFontSettings3.ccbFontColor.ItemIndex := MessColorFont; + fCreateNotify.frFontSettings3.sbFontSize.Value := MessSizeFont; + fCreateNotify.frFontSettings3.cbFontStyleDefault.ItemIndex := MessStyleFont; + + fCreateNotify.sbTimeMsg.Value := TimeMess; + fCreateNotify.cbEventsType.ItemIndex := TypeEvent; + fCreateNotify.edtIF.Text := TypeEdit; + fCreateNotify.sbWebServerPort.Value := port; + end; +end; + procedure TfCreateNotify.btnCreateEventClick(Sender: TObject); var OBSNotify: TOBSNotify; @@ -104,10 +144,10 @@ begin TimeMess := round(sbTimeMsg.Value); TypeEvent := cbEventsType.ItemIndex; TypeEdit := edtIF.Text; - Port := round(sbWebServerPort.Value); + port := round(sbWebServerPort.Value); end; if isEdit then - TTW_Bot.frOBS1.EdtNotify(OBSNotify) + TTW_Bot.frOBS1.EdtNotify(OBSNotify, oldPort) else TTW_Bot.frOBS1.AddNotify(OBSNotify); close; @@ -115,7 +155,7 @@ end; procedure TfCreateNotify.FormCreate(Sender: TObject); var - i: Integer; + i: integer; SavedColor: TAlphaColor; c: TComponent; ColorStr: string; @@ -254,11 +294,11 @@ procedure TfCreateNotify.FormShow(Sender: TObject); begin if isEdit then begin - btnCreateEvent.Text:='Изменить оповещение'; + btnCreateEvent.Text := 'Изменить оповещение'; end else begin - btnCreateEvent.Text:='Создать оповещение'; + btnCreateEvent.Text := 'Создать оповещение'; end; end;