OpenDirectory.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  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 "OpenDirectory.h"
  11. #include "WinConfiguration.h"
  12. //---------------------------------------------------------------------
  13. #pragma link "IEComboBox"
  14. #ifndef NO_RESOURCES
  15. #pragma resource "*.dfm"
  16. #endif
  17. //---------------------------------------------------------------------
  18. bool __fastcall DoOpenDirectoryDialog(TOpenDirectoryMode Mode, TOperationSide Side,
  19. AnsiString & Directory, TStrings * Directories, TTerminal * Terminal,
  20. bool AllowSwitch)
  21. {
  22. bool Result;
  23. TOpenDirectoryDialog * Dialog = new TOpenDirectoryDialog(Application);
  24. try
  25. {
  26. Dialog->Mode = Mode;
  27. Dialog->OperationSide = Side;
  28. Dialog->Directory = Directory;
  29. Dialog->Directories = Directories;
  30. Dialog->Terminal = Terminal;
  31. Dialog->AllowSwitch = AllowSwitch;
  32. Result = Dialog->Execute();
  33. if (Result)
  34. {
  35. Directory = Dialog->Directory;
  36. }
  37. }
  38. __finally
  39. {
  40. delete Dialog;
  41. }
  42. return Result;
  43. }
  44. //---------------------------------------------------------------------
  45. __fastcall TOpenDirectoryDialog::TOpenDirectoryDialog(TComponent * AOwner):
  46. TForm(AOwner)
  47. {
  48. UseSystemSettings(this);
  49. FOperationSide = osCurrent;
  50. OperationSide = osLocal;
  51. FBookmarkDragDest = -1;
  52. FTerminal = NULL;
  53. FSessionBookmarkList = new TBookmarkList();
  54. FSharedBookmarkList = new TBookmarkList();
  55. FSessionScrollOnDragOver = new TListBoxScrollOnDragOver(SessionBookmarksList, true);
  56. FSharedScrollOnDragOver = new TListBoxScrollOnDragOver(SharedBookmarksList, true);
  57. FixComboBoxResizeBug(LocalDirectoryEdit);
  58. InstallPathWordBreakProc(LocalDirectoryEdit);
  59. FixComboBoxResizeBug(RemoteDirectoryEdit);
  60. InstallPathWordBreakProc(RemoteDirectoryEdit);
  61. }
  62. //---------------------------------------------------------------------
  63. __fastcall TOpenDirectoryDialog::~TOpenDirectoryDialog()
  64. {
  65. SAFE_DESTROY(FSessionScrollOnDragOver);
  66. SAFE_DESTROY(FSharedScrollOnDragOver);
  67. SAFE_DESTROY(FSessionBookmarkList);
  68. SAFE_DESTROY(FSharedBookmarkList);
  69. }
  70. //---------------------------------------------------------------------
  71. void __fastcall TOpenDirectoryDialog::SetOperationSide(TOperationSide value)
  72. {
  73. if (OperationSide != value)
  74. {
  75. AnsiString ADirectory = Directory;
  76. FOperationSide = value;
  77. Directory = ADirectory;
  78. RemoteDirectoryEdit->Visible = False;
  79. LocalDirectoryEdit->Visible = False;
  80. CurrentEdit->Visible = True;
  81. EditLabel->FocusControl = CurrentEdit;
  82. UpdateControls();
  83. }
  84. }
  85. //---------------------------------------------------------------------------
  86. void __fastcall TOpenDirectoryDialog::SetDirectory(AnsiString value)
  87. {
  88. if (OperationSide == osRemote)
  89. {
  90. RemoteDirectoryEdit->Text = value;
  91. }
  92. else
  93. {
  94. LocalDirectoryEdit->Text = value;
  95. }
  96. DirectoryEditChange(NULL);
  97. }
  98. //---------------------------------------------------------------------------
  99. AnsiString __fastcall TOpenDirectoryDialog::GetDirectory()
  100. {
  101. if (OperationSide == osRemote)
  102. return UnixExcludeTrailingBackslash(RemoteDirectoryEdit->Text);
  103. else
  104. return ExcludeTrailingBackslash(LocalDirectoryEdit->Text);
  105. }
  106. //---------------------------------------------------------------------------
  107. TWinControl * __fastcall TOpenDirectoryDialog::GetCurrentEdit()
  108. {
  109. if (OperationSide == osRemote) return RemoteDirectoryEdit;
  110. else return LocalDirectoryEdit;
  111. }
  112. //---------------------------------------------------------------------------
  113. void __fastcall TOpenDirectoryDialog::ControlChange(TObject * /*Sender*/)
  114. {
  115. UpdateControls();
  116. }
  117. //---------------------------------------------------------------------------
  118. void __fastcall TOpenDirectoryDialog::UpdateBookmarkControls(
  119. TButton * AddBookmarkButton, TButton * RemoveBookmarkButton,
  120. TButton * ShortCutBookmarkButton,
  121. TButton * UpBookmarkButton, TButton * DownBookmarkButton,
  122. TListBox * BookmarksList, bool ListBoxUpdate)
  123. {
  124. EnableControl(AddBookmarkButton,
  125. !Directory.IsEmpty() && (FindBookmark(BookmarksList, Directory) < 0));
  126. EnableControl(RemoveBookmarkButton, BookmarksList->ItemIndex >= 0);
  127. if (ShortCutBookmarkButton != NULL)
  128. {
  129. EnableControl(ShortCutBookmarkButton, BookmarksList->ItemIndex >= 0);
  130. }
  131. EnableControl(UpBookmarkButton, BookmarksList->ItemIndex > 0);
  132. EnableControl(DownBookmarkButton, BookmarksList->ItemIndex >= 0 &&
  133. BookmarksList->ItemIndex < BookmarksList->Items->Count-1);
  134. if (ListBoxUpdate)
  135. {
  136. int MaxWidth = 0;
  137. for (int i = 0; i < BookmarksList->Items->Count; i++)
  138. {
  139. int Width = BookmarksList->Canvas->TextExtent(BookmarksList->Items->Strings[i]).cx;
  140. if (Width > MaxWidth)
  141. {
  142. MaxWidth = Width;
  143. }
  144. }
  145. BookmarksList->ScrollWidth = MaxWidth;
  146. MaxWidth += 6;
  147. if (BookmarksList->Items->Count > BookmarksList->ClientHeight / BookmarksList->ItemHeight)
  148. {
  149. MaxWidth += GetSystemMetrics(SM_CXVSCROLL);
  150. }
  151. if (MaxWidth > BookmarksList->Width)
  152. {
  153. int CWidth = ClientWidth + (MaxWidth - BookmarksList->Width);
  154. ClientWidth = CWidth > 700 ? 700 : CWidth;
  155. }
  156. }
  157. }
  158. //---------------------------------------------------------------------------
  159. void __fastcall TOpenDirectoryDialog::UpdateControls(bool ListBoxUpdate)
  160. {
  161. EnableControl(OKBtn, !Directory.IsEmpty());
  162. LocalDirectoryBrowseButton->Visible = (OperationSide == osLocal);
  163. SwitchButton->Visible = AllowSwitch;
  164. UpdateBookmarkControls(AddSessionBookmarkButton, RemoveSessionBookmarkButton,
  165. NULL, UpSessionBookmarkButton, DownSessionBookmarkButton,
  166. SessionBookmarksList, ListBoxUpdate);
  167. UpdateBookmarkControls(AddSharedBookmarkButton, RemoveSharedBookmarkButton,
  168. ShortCutSharedBookmarkButton, UpSharedBookmarkButton, DownSharedBookmarkButton,
  169. SharedBookmarksList, ListBoxUpdate);
  170. }
  171. //---------------------------------------------------------------------------
  172. void __fastcall TOpenDirectoryDialog::SetDirectories(TStrings * value)
  173. {
  174. dynamic_cast<TCustomComboBox*>(CurrentEdit)->Items = value;
  175. }
  176. //---------------------------------------------------------------------------
  177. TStrings * __fastcall TOpenDirectoryDialog::GetDirectories()
  178. {
  179. return RemoteDirectoryEdit->Items;
  180. }
  181. //---------------------------------------------------------------------------
  182. AnsiString __fastcall TOpenDirectoryDialog::BookmarkDirectory(TBookmark * Bookmark)
  183. {
  184. return OperationSide == osLocal ? Bookmark->Local : Bookmark->Remote;
  185. }
  186. //---------------------------------------------------------------------------
  187. AnsiString __fastcall TOpenDirectoryDialog::BookmarkText(TBookmark * Bookmark)
  188. {
  189. AnsiString Result = BookmarkDirectory(Bookmark);
  190. if (!Result.IsEmpty() && (Bookmark->ShortCut != 0))
  191. {
  192. Result = FORMAT("%s (%s)", (Result, ShortCutToText(Bookmark->ShortCut)));
  193. }
  194. return Result;
  195. }
  196. //---------------------------------------------------------------------------
  197. TBookmark * __fastcall TOpenDirectoryDialog::GetBookmark(TListBox * BookmarksList, int Index)
  198. {
  199. return dynamic_cast<TBookmark *>(BookmarksList->Items->Objects[Index]);
  200. }
  201. //---------------------------------------------------------------------------
  202. void __fastcall TOpenDirectoryDialog::LoadBookmarks(TListBox * ListBox,
  203. TBookmarkList * BookmarkList, TBookmarkList * Source)
  204. {
  205. if (Source != NULL)
  206. {
  207. BookmarkList->Assign(Source);
  208. }
  209. else
  210. {
  211. BookmarkList->Clear();
  212. }
  213. ListBox->Items->Clear();
  214. for (int i = 0; i < BookmarkList->Count; i++)
  215. {
  216. TBookmark * Bookmark = BookmarkList->Bookmarks[i];
  217. AnsiString Directory = BookmarkDirectory(Bookmark);
  218. if (!Directory.IsEmpty() && (FindBookmark(ListBox, Directory) < 0))
  219. {
  220. AnsiString Text = BookmarkText(Bookmark);
  221. ListBox->Items->AddObject(Text, Bookmark);
  222. }
  223. }
  224. }
  225. //---------------------------------------------------------------------------
  226. bool __fastcall TOpenDirectoryDialog::Execute()
  227. {
  228. bool Result;
  229. AnsiString 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() == mrOk);
  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: assert(false); 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. AnsiString 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 AnsiString 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 = mrOk;
  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. UpdateControls(true);
  494. if (Mode == odBrowse)
  495. {
  496. ActiveControl = CurrentEdit;
  497. }
  498. else
  499. {
  500. ActiveControl = GetBookmarksList(PageControl->ActivePage);
  501. }
  502. }
  503. //---------------------------------------------------------------------------
  504. void __fastcall TOpenDirectoryDialog::BookmarksListKeyDown(TObject * Sender,
  505. WORD & Key, TShiftState /*Shift*/)
  506. {
  507. if ((GetBookmarksList(Sender)->ItemIndex >= 0) && (Key == VK_DELETE))
  508. {
  509. RemoveBookmark(Sender);
  510. }
  511. }
  512. //---------------------------------------------------------------------------
  513. void __fastcall TOpenDirectoryDialog::LocalDirectoryBrowseButtonClick(
  514. TObject * /*Sender*/)
  515. {
  516. AnsiString Directory = LocalDirectoryEdit->Text;
  517. if (SelectDirectory(Directory, LoadStr(SELECT_LOCAL_DIRECTORY), true))
  518. {
  519. LocalDirectoryEdit->Text = Directory;
  520. DirectoryEditChange(NULL);
  521. }
  522. }
  523. //---------------------------------------------------------------------------
  524. void __fastcall TOpenDirectoryDialog::SwitchButtonClick(TObject * /*Sender*/)
  525. {
  526. WinConfiguration->UseLocationProfiles = true;
  527. }
  528. //---------------------------------------------------------------------------
  529. void __fastcall TOpenDirectoryDialog::HelpButtonClick(TObject * /*Sender*/)
  530. {
  531. FormHelp(this);
  532. }
  533. //---------------------------------------------------------------------------
  534. void __fastcall TOpenDirectoryDialog::BookmarksListEndDrag(TObject * Sender,
  535. TObject * /*Target*/, int /*X*/, int /*Y*/)
  536. {
  537. GetScrollOnDragOver(Sender)->EndDrag();
  538. }
  539. //---------------------------------------------------------------------------
  540. void __fastcall TOpenDirectoryDialog::ShortCutBookmarkButtonClick(
  541. TObject * Sender)
  542. {
  543. TBookmarkList * BookmarkList = GetBookmarkList(Sender);
  544. TListBox * BookmarksList = GetBookmarksList(Sender);
  545. int Index = BookmarksList->ItemIndex;
  546. TBookmark * Bookmark = GetBookmark(BookmarksList, Index);
  547. assert(Bookmark != NULL);
  548. TShortCuts ShortCuts;
  549. WinConfiguration->CustomCommandList->ShortCuts(ShortCuts);
  550. BookmarkList->ShortCuts(ShortCuts);
  551. TShortCut ShortCut = Bookmark->ShortCut;
  552. if (DoShortCutDialog(ShortCut, ShortCuts, HelpKeyword))
  553. {
  554. Bookmark->ShortCut = ShortCut;
  555. BookmarksList->Items->Strings[Index] = BookmarkText(Bookmark);
  556. UpdateControls(true);
  557. }
  558. }
  559. //---------------------------------------------------------------------------
  560. void __fastcall TOpenDirectoryDialog::PageControlChange(TObject * /*Sender*/)
  561. {
  562. BookmarkSelected(GetBookmarksList(PageControl->ActivePage));
  563. }
  564. //---------------------------------------------------------------------------