1 | unit UFormColumns;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, UVCard;
|
---|
7 |
|
---|
8 | type
|
---|
9 |
|
---|
10 | { TFormColumns }
|
---|
11 |
|
---|
12 | TFormColumns = class(TForm)
|
---|
13 | ButtonUp: TButton;
|
---|
14 | ButtonToLeft: TButton;
|
---|
15 | ButtonCancel: TButton;
|
---|
16 | ButtonOk: TButton;
|
---|
17 | ButtonToRight: TButton;
|
---|
18 | ButtonDown: TButton;
|
---|
19 | Label1: TLabel;
|
---|
20 | Label2: TLabel;
|
---|
21 | ListBoxActive: TListBox;
|
---|
22 | ListBoxAvailable: TListBox;
|
---|
23 | procedure ButtonDownClick(Sender: TObject);
|
---|
24 | procedure ButtonOkClick(Sender: TObject);
|
---|
25 | procedure ButtonToLeftClick(Sender: TObject);
|
---|
26 | procedure ButtonToRightClick(Sender: TObject);
|
---|
27 | procedure ButtonUpClick(Sender: TObject);
|
---|
28 | procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
---|
29 | procedure FormCreate(Sender: TObject);
|
---|
30 | procedure FormDestroy(Sender: TObject);
|
---|
31 | procedure FormShow(Sender: TObject);
|
---|
32 | procedure ListBoxActiveSelectionChange(Sender: TObject; User: boolean);
|
---|
33 | procedure ListBoxAvailableSelectionChange(Sender: TObject; User: boolean);
|
---|
34 | private
|
---|
35 | procedure SwapListItems(ListBox: TListBox; Index1, Index2: Integer);
|
---|
36 | public
|
---|
37 | ActiveColumns: TStringList;
|
---|
38 | AvailableColumns: TStringList;
|
---|
39 | procedure UpdateInterface;
|
---|
40 | end;
|
---|
41 |
|
---|
42 | var
|
---|
43 | FormColumns: TFormColumns;
|
---|
44 |
|
---|
45 |
|
---|
46 | implementation
|
---|
47 |
|
---|
48 | {$R *.lfm}
|
---|
49 |
|
---|
50 | uses
|
---|
51 | UCore;
|
---|
52 |
|
---|
53 | { TFormColumns }
|
---|
54 |
|
---|
55 | procedure TFormColumns.FormShow(Sender: TObject);
|
---|
56 | var
|
---|
57 | I: Integer;
|
---|
58 | begin
|
---|
59 | Core.PersistentForm1.Load(Self);
|
---|
60 |
|
---|
61 | ListBoxActive.Items.Assign(ActiveColumns);
|
---|
62 | ListBoxAvailable.Items.Assign(AvailableColumns);
|
---|
63 | ListBoxAvailable.Sorted := True;
|
---|
64 |
|
---|
65 | UpdateInterface;
|
---|
66 | end;
|
---|
67 |
|
---|
68 | procedure TFormColumns.ListBoxActiveSelectionChange(Sender: TObject;
|
---|
69 | User: boolean);
|
---|
70 | begin
|
---|
71 | UpdateInterface;
|
---|
72 | end;
|
---|
73 |
|
---|
74 | procedure TFormColumns.ListBoxAvailableSelectionChange(Sender: TObject;
|
---|
75 | User: boolean);
|
---|
76 | begin
|
---|
77 | UpdateInterface;
|
---|
78 | end;
|
---|
79 |
|
---|
80 | procedure TFormColumns.SwapListItems(ListBox: TListBox; Index1, Index2: Integer
|
---|
81 | );
|
---|
82 | var
|
---|
83 | Temp: string;
|
---|
84 | TempObject: TObject;
|
---|
85 | begin
|
---|
86 | Temp := ListBox.Items[Index1];
|
---|
87 | ListBox.Items[Index1] := ListBox.Items[Index2];
|
---|
88 | ListBox.Items[Index2] := Temp;
|
---|
89 | TempObject := ListBox.Items.Objects[Index1];
|
---|
90 | ListBox.Items.Objects[Index1] := ListBox.Items.Objects[Index2];
|
---|
91 | ListBox.Items.Objects[Index2] := TempObject;
|
---|
92 | end;
|
---|
93 |
|
---|
94 | procedure TFormColumns.FormClose(Sender: TObject; var CloseAction: TCloseAction
|
---|
95 | );
|
---|
96 | begin
|
---|
97 | Core.PersistentForm1.Save(Self);
|
---|
98 | end;
|
---|
99 |
|
---|
100 | procedure TFormColumns.ButtonUpClick(Sender: TObject);
|
---|
101 | begin
|
---|
102 | if ListBoxActive.ItemIndex > 0 then begin
|
---|
103 | SwapListItems(ListBoxActive, ListBoxActive.ItemIndex, ListBoxActive.ItemIndex - 1);
|
---|
104 | ListBoxActive.ItemIndex := ListBoxActive.ItemIndex - 1;
|
---|
105 | end;
|
---|
106 | end;
|
---|
107 |
|
---|
108 | procedure TFormColumns.ButtonDownClick(Sender: TObject);
|
---|
109 | begin
|
---|
110 | if ListBoxActive.ItemIndex < ListBoxActive.Items.Count - 1 then begin
|
---|
111 | SwapListItems(ListBoxActive, ListBoxActive.ItemIndex, ListBoxActive.ItemIndex + 1);
|
---|
112 | ListBoxActive.ItemIndex := ListBoxActive.ItemIndex + 1;
|
---|
113 | end;
|
---|
114 | end;
|
---|
115 |
|
---|
116 | procedure TFormColumns.ButtonOkClick(Sender: TObject);
|
---|
117 | begin
|
---|
118 | ActiveColumns.Assign(ListBoxActive.Items);
|
---|
119 | end;
|
---|
120 |
|
---|
121 | procedure TFormColumns.ButtonToLeftClick(Sender: TObject);
|
---|
122 | begin
|
---|
123 | if ListBoxActive.ItemIndex = -1 then begin
|
---|
124 | ListBoxActive.Items.AddObject(ListBoxAvailable.Items[ListBoxAvailable.ItemIndex],
|
---|
125 | ListBoxAvailable.Items.Objects[ListBoxAvailable.ItemIndex])
|
---|
126 | end else begin
|
---|
127 | ListBoxActive.Items.InsertObject(ListBoxActive.ItemIndex,
|
---|
128 | ListBoxAvailable.Items[ListBoxAvailable.ItemIndex],
|
---|
129 | ListBoxAvailable.Items.Objects[ListBoxAvailable.ItemIndex]);
|
---|
130 | end;
|
---|
131 | ListBoxAvailable.Items.Delete(ListBoxAvailable.ItemIndex);
|
---|
132 | end;
|
---|
133 |
|
---|
134 | procedure TFormColumns.ButtonToRightClick(Sender: TObject);
|
---|
135 | begin
|
---|
136 | ListBoxAvailable.Items.AddObject(ListBoxActive.Items[ListBoxActive.ItemIndex],
|
---|
137 | ListBoxActive.Items.Objects[ListBoxActive.ItemIndex]);
|
---|
138 | ListBoxActive.Items.Delete(ListBoxActive.ItemIndex);
|
---|
139 | end;
|
---|
140 |
|
---|
141 | procedure TFormColumns.FormCreate(Sender: TObject);
|
---|
142 | begin
|
---|
143 | Core.Translator.TranslateComponentRecursive(Self);
|
---|
144 | Core.ThemeManager1.UseTheme(Self);
|
---|
145 | ActiveColumns := TStringList.Create;
|
---|
146 | AvailableColumns := TStringList.Create;
|
---|
147 | end;
|
---|
148 |
|
---|
149 | procedure TFormColumns.FormDestroy(Sender: TObject);
|
---|
150 | begin
|
---|
151 | FreeAndNil(ActiveColumns);
|
---|
152 | FreeAndNil(AvailableColumns);
|
---|
153 | end;
|
---|
154 |
|
---|
155 | procedure TFormColumns.UpdateInterface;
|
---|
156 | begin
|
---|
157 | ButtonToLeft.Enabled := ListBoxAvailable.ItemIndex <> -1;
|
---|
158 | ButtonToRight.Enabled := ListBoxActive.ItemIndex <> -1;
|
---|
159 | ButtonDown.Enabled := (ListBoxActive.ItemIndex <> -1) and (ListBoxActive.ItemIndex < ListBoxActive.Items.Count - 1);
|
---|
160 | ButtonUp.Enabled := (ListBoxActive.ItemIndex <> -1) and (ListBoxActive.ItemIndex > 0);
|
---|
161 | end;
|
---|
162 |
|
---|
163 | end.
|
---|
164 |
|
---|