OpenDirectory.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. //---------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include <CoreMain.h>
  5. #include <Configuration.h>
  6. #include <RemoteFiles.h>
  7. #include <VCLCommon.h>
  8. #include <TextsWin.h>
  9. #include <Common.h>
  10. #include <Math.hpp>
  11. #include "OpenDirectory.h"
  12. #include "WinConfiguration.h"
  13. //---------------------------------------------------------------------
  14. #pragma link "IEComboBox"
  15. #ifndef NO_RESOURCES
  16. #pragma resource "*.dfm"
  17. #endif
  18. //---------------------------------------------------------------------
  19. bool __fastcall DoOpenDirectoryDialog(TOpenDirectoryMode Mode, TOperationSide Side,
  20. UnicodeString & Directory, TStrings * Directories, TTerminal * Terminal,
  21. bool AllowSwitch)
  22. {
  23. bool Result;
  24. TOpenDirectoryDialog * Dialog = new TOpenDirectoryDialog(Application);
  25. try
  26. {
  27. Dialog->Mode = Mode;
  28. Dialog->OperationSide = Side;
  29. Dialog->Directory = Directory;
  30. Dialog->Directories = Directories;
  31. Dialog->Terminal = Terminal;
  32. Dialog->AllowSwitch = AllowSwitch;
  33. Result = Dialog->Execute();
  34. if (Result)
  35. {
  36. Directory = Dialog->Directory;
  37. }
  38. }
  39. __finally
  40. {
  41. delete Dialog;
  42. }
  43. return Result;
  44. }
  45. //---------------------------------------------------------------------
  46. __fastcall TOpenDirectoryDialog::TOpenDirectoryDialog(TComponent * AOwner):
  47. TForm(AOwner)
  48. {
  49. UseSystemSettings(this);
  50. FOperationSide = osCurrent;
  51. OperationSide = osLocal;
  52. FBookmarkDragDest = -1;
  53. FTerminal = NULL;
  54. FSessionBookmarkList = new TBookmarkList();
  55. FSharedBookmarkList = new TBookmarkList();
  56. FSessionScrollOnDragOver = new TListBoxScrollOnDragOver(SessionBookmarksList, true);
  57. FSharedScrollOnDragOver = new TListBoxScrollOnDragOver(SharedBookmarksList, true);
  58. FixComboBoxResizeBug(LocalDirectoryEdit);
  59. FixComboBoxResizeBug(RemoteDirectoryEdit);
  60. }
  61. //---------------------------------------------------------------------
  62. __fastcall TOpenDirectoryDialog::~TOpenDirectoryDialog()
  63. {
  64. SAFE_DESTROY(FSessionScrollOnDragOver);
  65. SAFE_DESTROY(FSharedScrollOnDragOver);
  66. SAFE_DESTROY(FSessionBookmarkList);
  67. SAFE_DESTROY(FSharedBookmarkList);
  68. }
  69. //---------------------------------------------------------------------
  70. void __fastcall TOpenDirectoryDialog::SetOperationSide(TOperationSide value)
  71. {
  72. if (OperationSide != value)
  73. {
  74. UnicodeString ADirectory = Directory;
  75. FOperationSide = value;
  76. Directory = ADirectory;
  77. RemoteDirectoryEdit->Visible = False;
  78. LocalDirectoryEdit->Visible = False;
  79. CurrentEdit->Visible = True;
  80. EditLabel->FocusControl = CurrentEdit;
  81. UpdateControls();
  82. }
  83. }
  84. //---------------------------------------------------------------------------
  85. void __fastcall TOpenDirectoryDialog::SetDirectory(UnicodeString value)
  86. {
  87. if (OperationSide == osRemote)
  88. {
  89. RemoteDirectoryEdit->Text = value;
  90. }
  91. else
  92. {
  93. LocalDirectoryEdit->Text = value;
  94. }
  95. DirectoryEditChange(NULL);
  96. }
  97. //---------------------------------------------------------------------------
  98. UnicodeString __fastcall TOpenDirectoryDialog::GetDirectory()
  99. {
  100. if (OperationSide == osRemote)
  101. return UnixExcludeTrailingBackslash(RemoteDirectoryEdit->Text);
  102. else
  103. return ExcludeTrailingBackslash(LocalDirectoryEdit->Text);
  104. }
  105. //---------------------------------------------------------------------------
  106. TWinControl * __fastcall TOpenDirectoryDialog::GetCurrentEdit()
  107. {
  108. if (OperationSide == osRemote) return RemoteDirectoryEdit;
  109. else return LocalDirectoryEdit;
  110. }
  111. //---------------------------------------------------------------------------
  112. void __fastcall TOpenDirectoryDialog::ControlChange(TObject * /*Sender*/)
  113. {
  114. UpdateControls();
  115. }
  116. //---------------------------------------------------------------------------
  117. void __fastcall TOpenDirectoryDialog::UpdateBookmarkControls(
  118. TButton * AddBookmarkButton, TButton * RemoveBookmarkButton,
  119. TButton * ShortCutBookmarkButton,
  120. TButton * UpBookmarkButton, TButton * DownBookmarkButton,
  121. TListBox * BookmarksList, bool ListBoxUpdate)
  122. {
  123. EnableControl(AddBookmarkButton,
  124. !Directory.IsEmpty() && (FindBookmark(BookmarksList, Directory) < 0));
  125. EnableControl(RemoveBookmarkButton, BookmarksList->ItemIndex >= 0);
  126. if (ShortCutBookmarkButton != NULL)
  127. {
  128. EnableControl(ShortCutBookmarkButton, BookmarksList->ItemIndex >= 0);
  129. }
  130. EnableControl(UpBookmarkButton, BookmarksList->ItemIndex > 0);
  131. EnableControl(DownBookmarkButton, BookmarksList->ItemIndex >= 0 &&
  132. BookmarksList->ItemIndex < BookmarksList->Items->Count-1);
  133. if (ListBoxUpdate)
  134. {
  135. int MaxWidth = 0;
  136. for (int i = 0; i < BookmarksList->Items->Count; i++)
  137. {
  138. int Width = BookmarksList->Canvas->TextExtent(BookmarksList->Items->Strings[i]).cx;
  139. if (Width > MaxWidth)
  140. {
  141. MaxWidth = Width;
  142. }
  143. }
  144. BookmarksList->ScrollWidth = MaxWidth;
  145. MaxWidth += ScaleByTextHeight(this, 6);
  146. if (BookmarksList->Items->Count > BookmarksList->ClientHeight / BookmarksList->ItemHeight)
  147. {
  148. MaxWidth += GetSystemMetrics(SM_CXVSCROLL);
  149. }
  150. if (MaxWidth > BookmarksList->Width)
  151. {
  152. int CWidth = ClientWidth + (MaxWidth - BookmarksList->Width);
  153. ClientWidth = Min(CWidth, ScaleByTextHeight(this, 700));
  154. }
  155. }
  156. }
  157. //---------------------------------------------------------------------------
  158. void __fastcall TOpenDirectoryDialog::UpdateControls(bool ListBoxUpdate)
  159. {
  160. EnableControl(OKBtn, !Directory.IsEmpty());
  161. LocalDirectoryBrowseButton->Visible = (OperationSide == osLocal);
  162. SwitchButton->Visible = AllowSwitch;
  163. UpdateBookmarkControls(AddSessionBookmarkButton, RemoveSessionBookmarkButton,
  164. NULL, UpSessionBookmarkButton, DownSessionBookmarkButton,
  165. SessionBookmarksList, ListBoxUpdate);
  166. UpdateBookmarkControls(AddSharedBookmarkButton, RemoveSharedBookmarkButton,
  167. ShortCutSharedBookmarkButton, UpSharedBookmarkButton, DownSharedBookmarkButton,
  168. SharedBookmarksList, ListBoxUpdate);
  169. }
  170. //---------------------------------------------------------------------------
  171. void __fastcall TOpenDirectoryDialog::SetDirectories(TStrings * value)
  172. {
  173. dynamic_cast<TCustomComboBox*>(CurrentEdit)->Items = value;
  174. }
  175. //---------------------------------------------------------------------------
  176. TStrings * __fastcall TOpenDirectoryDialog::GetDirectories()
  177. {
  178. return RemoteDirectoryEdit->Items;
  179. }
  180. //---------------------------------------------------------------------------
  181. UnicodeString __fastcall TOpenDirectoryDialog::BookmarkDirectory(TBookmark * Bookmark)
  182. {
  183. return OperationSide == osLocal ? Bookmark->Local : Bookmark->Remote;
  184. }
  185. //---------------------------------------------------------------------------
  186. UnicodeString __fastcall TOpenDirectoryDialog::BookmarkText(TBookmark * Bookmark)
  187. {
  188. UnicodeString Result = BookmarkDirectory(Bookmark);
  189. if (!Result.IsEmpty() && (Bookmark->ShortCut != 0))
  190. {
  191. Result = FORMAT(L"%s (%s)", (Result, ShortCutToText(Bookmark->ShortCut)));
  192. }
  193. return Result;
  194. }
  195. //---------------------------------------------------------------------------
  196. TBookmark * __fastcall TOpenDirectoryDialog::GetBookmark(TListBox * BookmarksList, int Index)
  197. {
  198. return dynamic_cast<TBookmark *>(BookmarksList->Items->Objects[Index]);
  199. }
  200. //---------------------------------------------------------------------------
  201. void __fastcall TOpenDirectoryDialog::LoadBookmarks(TListBox * ListBox,
  202. TBookmarkList * BookmarkList, TBookmarkList * Source)
  203. {
  204. if (Source != NULL)
  205. {
  206. BookmarkList->Assign(Source);
  207. }
  208. else
  209. {
  210. BookmarkList->Clear();
  211. }
  212. Configuration->Usage->SetMax(L"MaxBookmarks", BookmarkList->Count);
  213. ListBox->Items->Clear();
  214. for (int i = 0; i < BookmarkList->Count; i++)
  215. {
  216. TBookmark * Bookmark = BookmarkList->Bookmarks[i];
  217. UnicodeString Directory = BookmarkDirectory(Bookmark);
  218. if (!Directory.IsEmpty() && (FindBookmark(ListBox, Directory) < 0))
  219. {
  220. UnicodeString Text = BookmarkText(Bookmark);
  221. ListBox->Items->AddObject(Text, Bookmark);
  222. }
  223. }
  224. }
  225. //---------------------------------------------------------------------------
  226. bool __fastcall TOpenDirectoryDialog::Execute()
  227. {
  228. bool Result;
  229. UnicodeString SessionKey;
  230. if (Terminal)
  231. {
  232. // cache session key, in case terminal is closed while the window is open
  233. SessionKey = Terminal->SessionData->SessionKey;
  234. LoadBookmarks(SessionBookmarksList, FSessionBookmarkList, WinConfiguration->Bookmarks[SessionKey]);
  235. LoadBookmarks(SharedBookmarksList, FSharedBookmarkList, WinConfiguration->SharedBookmarks);
  236. PageControl->ActivePage =
  237. WinConfiguration->UseSharedBookmarks ? SharedBookmarksSheet : SessionBookmarksSheet;
  238. DirectoryEditChange(NULL);
  239. if (Mode == odAddBookmark)
  240. {
  241. AddAsBookmark(PageControl->ActivePage);
  242. }
  243. }
  244. Result = (ShowModal() == DefaultResult(this));
  245. if (Terminal)
  246. {
  247. WinConfiguration->Bookmarks[SessionKey] = FSessionBookmarkList;
  248. WinConfiguration->SharedBookmarks = FSharedBookmarkList;
  249. WinConfiguration->UseSharedBookmarks = (PageControl->ActivePage == SharedBookmarksSheet);
  250. }
  251. return Result;
  252. }
  253. //---------------------------------------------------------------------------
  254. template<class T>
  255. typename T * GetBookmarkObject(TObject * Sender, T * SessionObject, T * SharedObject)
  256. {
  257. TControl * Control = dynamic_cast<TControl *>(Sender);
  258. assert(Control != NULL);
  259. switch (abs(Control->Tag))
  260. {
  261. case 1: return SessionObject;
  262. case 2: return SharedObject;
  263. default: FAIL; return NULL;
  264. }
  265. }
  266. //---------------------------------------------------------------------------
  267. TBookmarkList * TOpenDirectoryDialog::GetBookmarkList(TObject * Sender)
  268. {
  269. return GetBookmarkObject(Sender, FSessionBookmarkList, FSharedBookmarkList);
  270. }
  271. //---------------------------------------------------------------------------
  272. TListBox * TOpenDirectoryDialog::GetBookmarksList(TObject * Sender)
  273. {
  274. return GetBookmarkObject(Sender, SessionBookmarksList, SharedBookmarksList);
  275. }
  276. //---------------------------------------------------------------------------
  277. TListBoxScrollOnDragOver * TOpenDirectoryDialog::GetScrollOnDragOver(TObject * Sender)
  278. {
  279. return GetBookmarkObject(Sender, FSessionScrollOnDragOver, FSharedScrollOnDragOver);
  280. }
  281. //---------------------------------------------------------------------------
  282. void __fastcall TOpenDirectoryDialog::AddAsBookmark(TObject * Sender)
  283. {
  284. TBookmarkList * BookmarkList = GetBookmarkList(Sender);
  285. TListBox * BookmarksList = GetBookmarksList(Sender);
  286. if (Directory.IsEmpty() || (FindBookmark(BookmarksList, Directory) >= 0))
  287. {
  288. return;
  289. }
  290. TBookmark * Bookmark = new TBookmark;
  291. if (OperationSide == osRemote)
  292. {
  293. RemoteDirectoryEdit->SelectAll();
  294. Bookmark->Remote = Directory;
  295. }
  296. else
  297. {
  298. LocalDirectoryEdit->SelectAll();
  299. Bookmark->Local = Directory;
  300. }
  301. Bookmark->Name = Directory;
  302. // would alway be equal to Directory atm,
  303. // as only difference can be a shorcut, which is not set
  304. UnicodeString Text = BookmarkText(Bookmark);
  305. if (BookmarksList->ItemIndex >= 0)
  306. {
  307. int PrevItemIndex = BookmarksList->ItemIndex;
  308. BookmarkList->InsertBefore(
  309. GetBookmark(BookmarksList, BookmarksList->ItemIndex), Bookmark);
  310. BookmarksList->Items->InsertObject(BookmarksList->ItemIndex, Text, Bookmark);
  311. BookmarksList->ItemIndex = PrevItemIndex;
  312. }
  313. else
  314. {
  315. BookmarkList->Add(Bookmark);
  316. BookmarksList->Items->AddObject(Text, Bookmark);
  317. BookmarksList->ItemIndex = BookmarksList->Items->Count-1;
  318. }
  319. UpdateControls(true);
  320. }
  321. //---------------------------------------------------------------------------
  322. void __fastcall TOpenDirectoryDialog::AddBookmarkButtonClick(TObject * Sender)
  323. {
  324. AddAsBookmark(Sender);
  325. }
  326. //---------------------------------------------------------------------------
  327. void __fastcall TOpenDirectoryDialog::RemoveBookmark(TObject * Sender)
  328. {
  329. TBookmarkList * BookmarkList = GetBookmarkList(Sender);
  330. TListBox * BookmarksList = GetBookmarksList(Sender);
  331. int PrevItemIndex = BookmarksList->ItemIndex;
  332. TBookmark * Bookmark = GetBookmark(BookmarksList, PrevItemIndex);
  333. assert(Bookmark != NULL);
  334. BookmarkList->Delete(Bookmark);
  335. BookmarksList->Items->Delete(PrevItemIndex);
  336. if (PrevItemIndex < BookmarksList->Items->Count)
  337. {
  338. BookmarksList->ItemIndex = PrevItemIndex;
  339. }
  340. else
  341. {
  342. BookmarksList->ItemIndex = BookmarksList->Items->Count-1;
  343. }
  344. UpdateControls(true);
  345. BookmarkSelected(Sender);
  346. }
  347. //---------------------------------------------------------------------------
  348. void __fastcall TOpenDirectoryDialog::RemoveBookmarkButtonClick(TObject * Sender)
  349. {
  350. RemoveBookmark(Sender);
  351. }
  352. //---------------------------------------------------------------------------
  353. Integer __fastcall TOpenDirectoryDialog::FindBookmark(TListBox * BookmarksList, const UnicodeString Bookmark)
  354. {
  355. if (OperationSide == osRemote)
  356. {
  357. for (int Index = 0; Index < BookmarksList->Items->Count; Index++)
  358. {
  359. TBookmark * ABookmark = GetBookmark(BookmarksList, Index);
  360. if (AnsiCompareStr(BookmarkDirectory(ABookmark), Bookmark) == 0)
  361. {
  362. return Index;
  363. }
  364. }
  365. }
  366. else
  367. {
  368. for (int Index = 0; Index < BookmarksList->Items->Count; Index++)
  369. {
  370. TBookmark * ABookmark = GetBookmark(BookmarksList, Index);
  371. if (AnsiCompareText(BookmarkDirectory(ABookmark), Bookmark) == 0)
  372. {
  373. return Index;
  374. }
  375. }
  376. }
  377. return -1;
  378. }
  379. //---------------------------------------------------------------------------
  380. void __fastcall TOpenDirectoryDialog::BookmarkSelected(TObject * Sender)
  381. {
  382. TListBox * BookmarksList = GetBookmarksList(Sender);
  383. if (BookmarksList->ItemIndex >= 0)
  384. {
  385. Directory = BookmarkDirectory(GetBookmark(BookmarksList, BookmarksList->ItemIndex));
  386. }
  387. UpdateControls();
  388. }
  389. //---------------------------------------------------------------------------
  390. void __fastcall TOpenDirectoryDialog::BookmarksListClick(TObject * Sender)
  391. {
  392. BookmarkSelected(Sender);
  393. }
  394. //---------------------------------------------------------------------------
  395. void __fastcall TOpenDirectoryDialog::BookmarkMove(TObject * Sender,
  396. int Source, int Dest)
  397. {
  398. TBookmarkList * BookmarkList = GetBookmarkList(Sender);
  399. TListBox * BookmarksList = GetBookmarksList(Sender);
  400. if (Source >= 0 && Source < BookmarksList->Items->Count &&
  401. Dest >= 0 && Dest < BookmarksList->Items->Count)
  402. {
  403. BookmarkList->MoveTo(
  404. GetBookmark(BookmarksList, Dest),
  405. GetBookmark(BookmarksList, Source),
  406. Source > Dest);
  407. BookmarksList->Items->Move(Source, Dest);
  408. BookmarksList->ItemIndex = Dest;
  409. BookmarksList->SetFocus();
  410. UpdateControls();
  411. }
  412. }
  413. //---------------------------------------------------------------------------
  414. void __fastcall TOpenDirectoryDialog::BookmarkButtonClick(TObject * Sender)
  415. {
  416. TControl * Control = dynamic_cast<TControl *>(Sender);
  417. BookmarkMove(Sender,
  418. GetBookmarksList(Sender)->ItemIndex,
  419. GetBookmarksList(Sender)->ItemIndex + (Control->Tag / abs(Control->Tag)));
  420. UpdateControls();
  421. }
  422. //---------------------------------------------------------------------------
  423. bool __fastcall TOpenDirectoryDialog::AllowBookmarkDrag(TObject * Sender, int X, int Y)
  424. {
  425. FBookmarkDragDest = GetBookmarksList(Sender)->ItemAtPos(TPoint(X, Y), true);
  426. return (FBookmarkDragDest >= 0) && (FBookmarkDragDest != FBookmarkDragSource);
  427. }
  428. //---------------------------------------------------------------------------
  429. void __fastcall TOpenDirectoryDialog::BookmarksListStartDrag(
  430. TObject * Sender , TDragObject *& /*DragObject*/)
  431. {
  432. FBookmarkDragSource = GetBookmarksList(Sender)->ItemIndex;
  433. FBookmarkDragDest = -1;
  434. GetScrollOnDragOver(Sender)->StartDrag();
  435. }
  436. //---------------------------------------------------------------------------
  437. void __fastcall TOpenDirectoryDialog::BookmarksListDragOver(
  438. TObject * Sender, TObject *Source, int X, int Y, TDragState /*State*/,
  439. bool &Accept)
  440. {
  441. if (Source == GetBookmarksList(Sender))
  442. {
  443. Accept = AllowBookmarkDrag(Sender, X, Y);
  444. GetScrollOnDragOver(Sender)->DragOver(TPoint(X, Y));
  445. }
  446. }
  447. //---------------------------------------------------------------------------
  448. void __fastcall TOpenDirectoryDialog::BookmarksListDragDrop(
  449. TObject * Sender, TObject *Source, int X, int Y)
  450. {
  451. if (Source == GetBookmarksList(Sender))
  452. {
  453. if (AllowBookmarkDrag(Sender, X, Y))
  454. {
  455. BookmarkMove(Sender, FBookmarkDragSource, FBookmarkDragDest);
  456. }
  457. }
  458. }
  459. //---------------------------------------------------------------------------
  460. void __fastcall TOpenDirectoryDialog::SelectBookmark(TListBox * BookmarksList)
  461. {
  462. int ItemIndex = FindBookmark(BookmarksList, Directory);
  463. if (ItemIndex >= 0)
  464. {
  465. BookmarksList->ItemIndex = ItemIndex;
  466. }
  467. }
  468. //---------------------------------------------------------------------------
  469. void __fastcall TOpenDirectoryDialog::DirectoryEditChange(TObject * /*Sender*/)
  470. {
  471. SelectBookmark(SessionBookmarksList);
  472. SelectBookmark(SharedBookmarksList);
  473. UpdateControls();
  474. }
  475. //---------------------------------------------------------------------------
  476. void __fastcall TOpenDirectoryDialog::BookmarksListDblClick(TObject * Sender)
  477. {
  478. if (GetBookmarksList(Sender)->ItemIndex >= 0)
  479. {
  480. ModalResult = DefaultResult(this);
  481. }
  482. }
  483. //---------------------------------------------------------------------------
  484. void __fastcall TOpenDirectoryDialog::SetMode(TOpenDirectoryMode value)
  485. {
  486. FMode = value;
  487. Caption = LoadStr(Mode == odBrowse ?
  488. OPEN_DIRECTORY_BROWSE_CAPTION : OPEN_DIRECTORY_ADD_BOOMARK_ACTION );
  489. }
  490. //---------------------------------------------------------------------------
  491. void __fastcall TOpenDirectoryDialog::FormShow(TObject * /*Sender*/)
  492. {
  493. InstallPathWordBreakProc(LocalDirectoryEdit);
  494. InstallPathWordBreakProc(RemoteDirectoryEdit);
  495. UpdateControls(true);
  496. if (Mode == odBrowse)
  497. {
  498. ActiveControl = CurrentEdit;
  499. }
  500. else
  501. {
  502. ActiveControl = GetBookmarksList(PageControl->ActivePage);
  503. }
  504. }
  505. //---------------------------------------------------------------------------
  506. void __fastcall TOpenDirectoryDialog::BookmarksListKeyDown(TObject * Sender,
  507. WORD & Key, TShiftState /*Shift*/)
  508. {
  509. if ((GetBookmarksList(Sender)->ItemIndex >= 0) && (Key == VK_DELETE))
  510. {
  511. RemoveBookmark(Sender);
  512. }
  513. }
  514. //---------------------------------------------------------------------------
  515. void __fastcall TOpenDirectoryDialog::LocalDirectoryBrowseButtonClick(
  516. TObject * /*Sender*/)
  517. {
  518. UnicodeString Directory = LocalDirectoryEdit->Text;
  519. if (SelectDirectory(Directory, LoadStr(SELECT_LOCAL_DIRECTORY), true))
  520. {
  521. LocalDirectoryEdit->Text = Directory;
  522. DirectoryEditChange(NULL);
  523. }
  524. }
  525. //---------------------------------------------------------------------------
  526. void __fastcall TOpenDirectoryDialog::SwitchButtonClick(TObject * /*Sender*/)
  527. {
  528. WinConfiguration->UseLocationProfiles = true;
  529. }
  530. //---------------------------------------------------------------------------
  531. void __fastcall TOpenDirectoryDialog::HelpButtonClick(TObject * /*Sender*/)
  532. {
  533. FormHelp(this);
  534. }
  535. //---------------------------------------------------------------------------
  536. void __fastcall TOpenDirectoryDialog::BookmarksListEndDrag(TObject * Sender,
  537. TObject * /*Target*/, int /*X*/, int /*Y*/)
  538. {
  539. GetScrollOnDragOver(Sender)->EndDrag();
  540. }
  541. //---------------------------------------------------------------------------
  542. void __fastcall TOpenDirectoryDialog::ShortCutBookmarkButtonClick(
  543. TObject * Sender)
  544. {
  545. TBookmarkList * BookmarkList = GetBookmarkList(Sender);
  546. TListBox * BookmarksList = GetBookmarksList(Sender);
  547. int Index = BookmarksList->ItemIndex;
  548. TBookmark * Bookmark = GetBookmark(BookmarksList, Index);
  549. assert(Bookmark != NULL);
  550. TShortCuts ShortCuts;
  551. WinConfiguration->CustomCommandList->ShortCuts(ShortCuts);
  552. BookmarkList->ShortCuts(ShortCuts);
  553. TShortCut ShortCut = Bookmark->ShortCut;
  554. if (DoShortCutDialog(ShortCut, ShortCuts, HelpKeyword))
  555. {
  556. Bookmark->ShortCut = ShortCut;
  557. BookmarksList->Items->Strings[Index] = BookmarkText(Bookmark);
  558. UpdateControls(true);
  559. }
  560. }
  561. //---------------------------------------------------------------------------
  562. void __fastcall TOpenDirectoryDialog::PageControlChange(TObject * /*Sender*/)
  563. {
  564. BookmarkSelected(GetBookmarksList(PageControl->ActivePage));
  565. }
  566. //---------------------------------------------------------------------------