Browse Source

Code-Styling: UCTRLWallet.pas

Herman Schoenfeld 7 years ago
parent
commit
5bed55e294
1 changed files with 23 additions and 57 deletions
  1. 23 57
      src/gui/UCTRLWallet.pas

+ 23 - 57
src/gui/UCTRLWallet.pas

@@ -296,23 +296,17 @@ var
   str: ansistring;
   str: ansistring;
 begin
 begin
   // determine current selection
   // determine current selection
-  if cbAccounts.ItemIndex >= 1 then
-  begin
-    if cbAccounts.ItemIndex < cbAccounts.Items.Count - 1 then
-    begin
+  if cbAccounts.ItemIndex >= 1 then begin
+    if cbAccounts.ItemIndex < cbAccounts.Items.Count - 1 then begin
       last_key := TBox<TAccountKey>(
       last_key := TBox<TAccountKey>(
         cbAccounts.Items.Objects[cbAccounts.ItemIndex]).Value;
         cbAccounts.Items.Objects[cbAccounts.ItemIndex]).Value;
       selectFirst := False;
       selectFirst := False;
       selectLast := False;
       selectLast := False;
-    end
-    else
-    begin
+    end else begin
       selectFirst := False;
       selectFirst := False;
       selectLast := True;
       selectLast := True;
     end;
     end;
-  end
-  else
-  begin
+  end else begin
     selectFirst := True;
     selectFirst := True;
     selectLast := False;
     selectLast := False;
   end;
   end;
@@ -325,18 +319,14 @@ begin
       cbAccounts.Items.Objects[i].Free;
       cbAccounts.Items.Objects[i].Free;
     cbAccounts.Items.Clear;
     cbAccounts.Items.Clear;
     // add new items
     // add new items
-    for i := 0 to TWallet.Keys.Count - 1 do
-    begin
+    for i := 0 to TWallet.Keys.Count - 1 do begin
       // get i'th key
       // get i'th key
       key := TWallet.Keys.Key[i];
       key := TWallet.Keys.Key[i];
       // fix name
       // fix name
-      if (key.Name = '') then
-      begin
+      if (key.Name = '') then begin
         str := 'Sha256=' + TCrypto.ToHexaString(TCrypto.DoSha256(
         str := 'Sha256=' + TCrypto.ToHexaString(TCrypto.DoSha256(
           TAccountComp.AccountKey2RawString(key.AccountKey)));
           TAccountComp.AccountKey2RawString(key.AccountKey)));
-      end
-      else
-      begin
+      end else begin
         str := key.Name;
         str := key.Name;
       end;
       end;
       if not Assigned(key.PrivateKey) then
       if not Assigned(key.PrivateKey) then
@@ -353,13 +343,9 @@ begin
     cbAccounts.ItemIndex := 0
     cbAccounts.ItemIndex := 0
   else if selectLast then
   else if selectLast then
     cbAccounts.ItemIndex := cbAccounts.Items.Count - 1
     cbAccounts.ItemIndex := cbAccounts.Items.Count - 1
-  else
-  begin
-    for i := 1 to cbAccounts.Items.Count - 2 do
-    begin
-      if TAccountKeyEqualityComparer.AreEqual(TBox<TAccountKey>(
-        cbAccounts.Items.Objects[i]).Value, last_key) then
-      begin
+  else begin
+    for i := 1 to cbAccounts.Items.Count - 2 do begin
+      if TAccountKeyEqualityComparer.AreEqual(TBox<TAccountKey>( cbAccounts.Items.Objects[i]).Value, last_key) then begin
         cbAccounts.ItemIndex := i;
         cbAccounts.ItemIndex := i;
         exit;
         exit;
       end;
       end;
@@ -367,8 +353,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-function TCTRLWallet.GetAccounts(
-  const AccountNumbers: TArray<cardinal>): TArray<TAccount>;
+function TCTRLWallet.GetAccounts(const AccountNumbers: TArray<cardinal>): TArray<TAccount>;
 var
 var
   acc: TAccount;
   acc: TAccount;
   safeBox: TPCSafeBox;
   safeBox: TPCSafeBox;
@@ -384,13 +369,10 @@ begin
     LContainer.Clear;
     LContainer.Clear;
     try
     try
       // load selected user accounts
       // load selected user accounts
-      for i := Low(AccountNumbers) to High(AccountNumbers) do
-      begin
+      for i := Low(AccountNumbers) to High(AccountNumbers) do begin
         acc := safeBox.Account(AccountNumbers[i]);
         acc := safeBox.Account(AccountNumbers[i]);
         if keys.IndexOfAccountKey(acc.accountInfo.accountKey) >= 0 then
         if keys.IndexOfAccountKey(acc.accountInfo.accountKey) >= 0 then
-        begin
           LContainer.Add(acc);
           LContainer.Add(acc);
-        end;
       end;
       end;
     finally
     finally
       safeBox.EndThreadSave;
       safeBox.EndThreadSave;
@@ -399,7 +381,6 @@ begin
   finally
   finally
     LContainer.Free;
     LContainer.Free;
   end;
   end;
-
 end;
 end;
 
 
 procedure TCTRLWallet.SetAccountsMode(AMode: TCTRLWalletAccountsMode);
 procedure TCTRLWallet.SetAccountsMode(AMode: TCTRLWalletAccountsMode);
@@ -504,20 +485,16 @@ var
 begin
 begin
   selectedAccounts := GC.AddObject(TList<cardinal>.Create) as TList<cardinal>;
   selectedAccounts := GC.AddObject(TList<cardinal>.Create) as TList<cardinal>;
 
 
-  if ASelection.RowCount > 0 then
-  begin
+  if ASelection.RowCount > 0 then begin
     for row := ASelection.Row to (ASelection.Row + ASelection.RowCount - 1) do begin
     for row := ASelection.Row to (ASelection.Row + ASelection.RowCount - 1) do begin
-      if (TAccountComp.AccountTxtNumberToAccountNumber(
-        FAccountsGrid.Rows[row].Account, acc)) then
+      if (TAccountComp.AccountTxtNumberToAccountNumber(FAccountsGrid.Rows[row].Account, acc)) then
         selectedAccounts.Add(acc);
         selectedAccounts.Add(acc);
     end;
     end;
     FOperationsDataSource.Accounts := selectedAccounts.ToArray;
     FOperationsDataSource.Accounts := selectedAccounts.ToArray;
-    FOperationsGrid.Caption.Text :=
-      IIF(ASelection.RowCount = 1, Format('Account: %s', [TAccountComp.AccountNumberToAccountTxtNumber(selectedAccounts[0])]), 'Selected Accounts');
+    FOperationsGrid.Caption.Text := IIF(ASelection.RowCount = 1, Format('Account: %s', [TAccountComp.AccountNumberToAccountTxtNumber(selectedAccounts[0])]), 'Selected Accounts');
     FOperationsGrid.RefreshGrid;
     FOperationsGrid.RefreshGrid;
-  end else begin
+  end else
     OperationsMode := womAllAccounts;
     OperationsMode := womAllAccounts;
-  end;
 end;
 end;
 
 
 procedure TCTRLWallet.OnOperationSelected(Sender: TObject; constref ASelection: TVisualGridSelection);
 procedure TCTRLWallet.OnOperationSelected(Sender: TObject; constref ASelection: TVisualGridSelection);
@@ -578,26 +555,15 @@ var
 begin
 begin
   miSep1.Visible := ASelection.RowCount = 1;
   miSep1.Visible := ASelection.RowCount = 1;
   miAccountInfo.Visible := ASelection.RowCount = 1;
   miAccountInfo.Visible := ASelection.RowCount = 1;
-  miSendPASC.Caption :=
-    IIF(ASelection.RowCount = 1, 'Send PASC', 'Send All PASC');
-   miChangeKey.Caption :=
-    IIF(ASelection.RowCount = 1, 'Change Key', 'Change All Key');
-  miEnlistAccountsForSale.Caption :=
-    IIF(ASelection.RowCount = 1, 'Enlist Account For Sale',
-    'Enlist All Account For Sale');
-  miDelistAccountsFromSale.Caption :=
-    IIF(ASelection.RowCount = 1, 'Delist Account From Sale',
-    'Delist All Account From Sale');
-  if ASelection.RowCount = 1 then
-  begin
-    if not TAccountComp.AccountTxtNumberToAccountNumber(
-      FAccountsGrid.Rows[ASelection.Row].Account, accNo) then
-    begin
+  miSendPASC.Caption := IIF(ASelection.RowCount = 1, 'Send PASC', 'Send All PASC');
+  miChangeKey.Caption := IIF(ASelection.RowCount = 1, 'Change Key', 'Change All Key');
+  miEnlistAccountsForSale.Caption := IIF(ASelection.RowCount = 1, 'Enlist Account For Sale', 'Enlist All Account For Sale');
+  miDelistAccountsFromSale.Caption := IIF(ASelection.RowCount = 1, 'Delist Account From Sale', 'Delist All Account From Sale');
+  if ASelection.RowCount = 1 then begin
+    if not TAccountComp.AccountTxtNumberToAccountNumber(FAccountsGrid.Rows[ASelection.Row].Account, accNo) then
       raise Exception.Create('Error Parsing Account Number From Grid');
       raise Exception.Create('Error Parsing Account Number From Grid');
-    end;
     account := TNode.Node.Operations.SafeBoxTransaction.Account(accNo);
     account := TNode.Node.Operations.SafeBoxTransaction.Account(accNo);
-    miEnlistAccountsForSale.Visible :=
-      IIF(TAccountComp.IsAccountForSale(account.accountInfo), False, True);
+    miEnlistAccountsForSale.Visible := IIF(TAccountComp.IsAccountForSale(account.accountInfo), False, True);
     miDelistAccountsFromSale.Visible := not miEnlistAccountsForSale.Visible;
     miDelistAccountsFromSale.Visible := not miEnlistAccountsForSale.Visible;
   end;
   end;
   APopupMenu := mnuAccountsPopup;
   APopupMenu := mnuAccountsPopup;