OpenDirectory.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  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. UnicodeString & 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. UnicodeString 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(UnicodeString 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. UnicodeString __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. UnicodeString __fastcall TOpenDirectoryDialog::BookmarkDirectory(TBookmark * Bookmark)
  183. {
  184. return OperationSide == osLocal ? Bookmark->Local : Bookmark->Remote;
  185. }
  186. //---------------------------------------------------------------------------
  187. UnicodeString __fastcall TOpenDirectoryDialog::BookmarkText(TBookmark * Bookmark)
  188. {
  189. UnicodeString Result = BookmarkDirectory(Bookmark);
  190. if (!Result.IsEmpty() && (Bookmark->ShortCut != 0))
  191. {
  192. Result = FORMAT(L"%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. Configuration->Usage->SetMax(L"MaxBookmarks", BookmarkList->Count);
  214. ListBox->Items->Clear();
  215. for (int i = 0; i < BookmarkList->Count; i++)
  216. {
  217. TBookmark * Bookmark = BookmarkList->Bookmarks[i];
  218. UnicodeString Directory = BookmarkDirectory(Bookmark);
  219. if (!Directory.IsEmpty() && (FindBookmark(ListBox, Directory) < 0))
  220. {
  221. UnicodeString Text = BookmarkText(Bookmark);
  222. ListBox->Items->AddObject(Text, Bookmark);
  223. }
  224. }
  225. }
  226. //---------------------------------------------------------------------------
  227. bool __fastcall TOpenDirectoryDialog::Execute()
  228. {
  229. bool Result;
  230. UnicodeString SessionKey;
  231. if (Terminal)
  232. {
  233. // cache session key, in case terminal is closed while the window is open
  234. SessionKey = Terminal->SessionData->SessionKey;
  235. LoadBookmarks(SessionBookmarksList, FSessionBookmarkList, WinConfiguration->Bookmarks[SessionKey]);
  236. LoadBookmarks(SharedBookmarksList, FSharedBookmarkList, WinConfiguration->SharedBookmarks);
  237. PageControl->ActivePage =
  238. WinConfiguration->UseSharedBookmarks ? SharedBookmarksSheet : SessionBookmarksSheet;
  239. DirectoryEditChange(NULL);
  240. if (Mode == odAddBookmark)
  241. {
  242. AddAsBookmark(PageControl->ActivePage);
  243. }
  244. }
  245. Result = (ShowModal() == mrOk);
  246. if (Terminal)
  247. {
  248. WinConfiguration->Bookmarks[SessionKey] = FSessionBookmarkList;
  249. WinConfiguration->SharedBookmarks = FSharedBookmarkList;
  250. WinConfiguration->UseSharedBookmarks = (PageControl->ActivePage == SharedBookmarksSheet);
  251. }
  252. return Result;
  253. }
  254. //---------------------------------------------------------------------------
  255. template<class T>
  256. typename T * GetBookmarkObject(TObject * Sender, T * SessionObject, T * SharedObject)
  257. {
  258. TControl * Control = dynamic_cast<TControl *>(Sender);
  259. assert(Control != NULL);
  260. switch (abs(Control->Tag))
  261. {
  262. case 1: return SessionObject;
  263. case 2: return SharedObject;
  264. default: assert(false); return NULL;
  265. }
  266. }
  267. //---------------------------------------------------------------------------
  268. TBookmarkList * TOpenDirectoryDialog::GetBookmarkList(TObject * Sender)
  269. {
  270. return GetBookmarkObject(Sender, FSessionBookmarkList, FSharedBookmarkList);
  271. }
  272. //---------------------------------------------------------------------------
  273. TListBox * TOpenDirectoryDialog::GetBookmarksList(TObject * Sender)
  274. {
  275. return GetBookmarkObject(Sender, SessionBookmarksList, SharedBookmarksList);
  276. }
  277. //---------------------------------------------------------------------------
  278. TListBoxScrollOnDragOver * TOpenDirectoryDialog::GetScrollOnDragOver(TObject * Sender)
  279. {
  280. return GetBookmarkObject(Sender, FSessionScrollOnDragOver, FSharedScrollOnDragOver);
  281. }
  282. //---------------------------------------------------------------------------
  283. void __fastcall TOpenDirectoryDialog::AddAsBookmark(TObject * Sender)
  284. {
  285. TBookmarkList * BookmarkList = GetBookmarkList(Sender);
  286. TListBox * BookmarksList = GetBookmarksList(Sender);
  287. if (Directory.IsEmpty() || (FindBookmark(BookmarksList, Directory) >= 0))
  288. {
  289. return;
  290. }
  291. TBookmark * Bookmark = new TBookmark;
  292. if (OperationSide == osRemote)
  293. {
  294. RemoteDirectoryEdit->SelectAll();
  295. Bookmark->Remote = Directory;
  296. }
  297. else
  298. {
  299. LocalDirectoryEdit->SelectAll();
  300. Bookmark->Local = Directory;
  301. }
  302. Bookmark->Name = Directory;
  303. // would alway be equal to Directory atm,
  304. // as only difference can be a shorcut, which is not set
  305. UnicodeString Text = BookmarkText(Bookmark);
  306. if (BookmarksList->ItemIndex >= 0)
  307. {
  308. int PrevItemIndex = BookmarksList->ItemIndex;
  309. BookmarkList->InsertBefore(
  310. GetBookmark(BookmarksList, BookmarksList->ItemIndex), Bookmark);
  311. BookmarksList->Items->InsertObject(BookmarksList->ItemIndex, Text, Bookmark);
  312. BookmarksList->ItemIndex = PrevItemIndex;
  313. }
  314. else
  315. {
  316. BookmarkList->Add(Bookmark);
  317. BookmarksList->Items->AddObject(Text, Bookmark);
  318. BookmarksList->ItemIndex = BookmarksList->Items->Count-1;
  319. }
  320. UpdateControls(true);
  321. }
  322. //---------------------------------------------------------------------------
  323. void __fastcall TOpenDirectoryDialog::AddBookmarkButtonClick(TObject * Sender)
  324. {
  325. AddAsBookmark(Sender);
  326. }
  327. //---------------------------------------------------------------------------
  328. void __fastcall TOpenDirectoryDialog::RemoveBookmark(TObject * Sender)
  329. {
  330. TBookmarkList * BookmarkList = GetBookmarkList(Sender);
  331. TListBox * BookmarksList = GetBookmarksList(Sender);
  332. int PrevItemIndex = BookmarksList->ItemIndex;
  333. TBookmark * Bookmark = GetBookmark(BookmarksList, PrevItemIndex);
  334. assert(Bookmark != NULL);
  335. BookmarkList->Delete(Bookmark);
  336. BookmarksList->Items->Delete(PrevItemIndex);
  337. if (PrevItemIndex < BookmarksList->Items->Count)
  338. {
  339. BookmarksList->ItemIndex = PrevItemIndex;
  340. }
  341. else
  342. {
  343. BookmarksList->ItemIndex = BookmarksList->Items->Count-1;
  344. }
  345. UpdateControls(true);
  346. BookmarkSelected(Sender);
  347. }
  348. //---------------------------------------------------------------------------
  349. void __fastcall TOpenDirectoryDialog::RemoveBookmarkButtonClick(TObject * Sender)
  350. {
  351. RemoveBookmark(Sender);
  352. }
  353. //---------------------------------------------------------------------------
  354. Integer __fastcall TOpenDirectoryDialog::FindBookmark(TListBox * BookmarksList, const UnicodeString Bookmark)
  355. {
  356. if (OperationSide == osRemote)
  357. {
  358. for (int Index = 0; Index < BookmarksList->Items->Count; Index++)
  359. {
  360. TBookmark * ABookmark = GetBookmark(BookmarksList, Index);
  361. if (AnsiCompareStr(BookmarkDirectory(ABookmark), Bookmark) == 0)
  362. {
  363. return Index;
  364. }
  365. }
  366. }
  367. else
  368. {
  369. for (int Index = 0; Index < BookmarksList->Items->Count; Index++)
  370. {
  371. TBookmark * ABookmark = GetBookmark(BookmarksList, Index);
  372. if (AnsiCompareText(BookmarkDirectory(ABookmark), Bookmark) == 0)
  373. {
  374. return Index;
  375. }
  376. }
  377. }
  378. return -1;
  379. }
  380. //---------------------------------------------------------------------------
  381. void __fastcall TOpenDirectoryDialog::BookmarkSelected(TObject * Sender)
  382. {
  383. TListBox * BookmarksList = GetBookmarksList(Sender);
  384. if (BookmarksList->ItemIndex >= 0)
  385. {
  386. Directory = BookmarkDirectory(GetBookmark(BookmarksList, BookmarksList->ItemIndex));
  387. }
  388. UpdateControls();
  389. }
  390. //---------------------------------------------------------------------------
  391. void __fastcall TOpenDirectoryDialog::BookmarksListClick(TObject * Sender)
  392. {
  393. BookmarkSelected(Sender);
  394. }
  395. //---------------------------------------------------------------------------
  396. void __fastcall TOpenDirectoryDialog::BookmarkMove(TObject * Sender,
  397. int Source, int Dest)
  398. {
  399. TBookmarkList * BookmarkList = GetBookmarkList(Sender);
  400. TListBox * BookmarksList = GetBookmarksList(Sender);
  401. if (Source >= 0 && Source < BookmarksList->Items->Count &&
  402. Dest >= 0 && Dest < BookmarksList->Items->Count)
  403. {
  404. BookmarkList->MoveTo(
  405. GetBookmark(BookmarksList, Dest),
  406. GetBookmark(BookmarksList, Source),
  407. Source > Dest);
  408. BookmarksList->Items->Move(Source, Dest);
  409. BookmarksList->ItemIndex = Dest;
  410. BookmarksList->SetFocus();
  411. UpdateControls();
  412. }
  413. }
  414. //---------------------------------------------------------------------------
  415. void __fastcall TOpenDirectoryDialog::BookmarkButtonClick(TObject * Sender)
  416. {
  417. TControl * Control = dynamic_cast<TControl *>(Sender);
  418. BookmarkMove(Sender,
  419. GetBookmarksList(Sender)->ItemIndex,
  420. GetBookmarksList(Sender)->ItemIndex + (Control->Tag / abs(Control->Tag)));
  421. UpdateControls();
  422. }
  423. //---------------------------------------------------------------------------
  424. bool __fastcall TOpenDirectoryDialog::AllowBookmarkDrag(TObject * Sender, int X, int Y)
  425. {
  426. FBookmarkDragDest = GetBookmarksList(Sender)->ItemAtPos(TPoint(X, Y), true);
  427. return (FBookmarkDragDest >= 0) && (FBookmarkDragDest != FBookmarkDragSource);
  428. }
  429. //---------------------------------------------------------------------------
  430. void __fastcall TOpenDirectoryDialog::BookmarksListStartDrag(
  431. TObject * Sender , TDragObject *& /*DragObject*/)
  432. {
  433. FBookmarkDragSource = GetBookmarksList(Sender)->ItemIndex;
  434. FBookmarkDragDest = -1;
  435. GetScrollOnDragOver(Sender)->StartDrag();
  436. }
  437. //---------------------------------------------------------------------------
  438. void __fastcall TOpenDirectoryDialog::BookmarksListDragOver(
  439. TObject * Sender, TObject *Source, int X, int Y, TDragState /*State*/,
  440. bool &Accept)
  441. {
  442. if (Source == GetBookmarksList(Sender))
  443. {
  444. Accept = AllowBookmarkDrag(Sender, X, Y);
  445. GetScrollOnDragOver(Sender)->DragOver(TPoint(X, Y));
  446. }
  447. }
  448. //---------------------------------------------------------------------------
  449. void __fastcall TOpenDirectoryDialog::BookmarksListDragDrop(
  450. TObject * Sender, TObject *Source, int X, int Y)
  451. {
  452. if (Source == GetBookmarksList(Sender))
  453. {
  454. if (AllowBookmarkDrag(Sender, X, Y))
  455. {
  456. BookmarkMove(Sender, FBookmarkDragSource, FBookmarkDragDest);
  457. }
  458. }
  459. }
  460. //---------------------------------------------------------------------------
  461. void __fastcall TOpenDirectoryDialog::SelectBookmark(TListBox * BookmarksList)
  462. {
  463. int ItemIndex = FindBookmark(BookmarksList, Directory);
  464. if (ItemIndex >= 0)
  465. {
  466. BookmarksList->ItemIndex = ItemIndex;
  467. }
  468. }
  469. //---------------------------------------------------------------------------
  470. void __fastcall TOpenDirectoryDialog::DirectoryEditChange(TObject * /*Sender*/)
  471. {
  472. SelectBookmark(SessionBookmarksList);
  473. SelectBookmark(SharedBookmarksList);
  474. UpdateControls();
  475. }
  476. //---------------------------------------------------------------------------
  477. void __fastcall TOpenDirectoryDialog::BookmarksListDblClick(TObject * Sender)
  478. {
  479. if (GetBookmarksList(Sender)->ItemIndex >= 0)
  480. {
  481. ModalResult = mrOk;
  482. }
  483. }
  484. //---------------------------------------------------------------------------
  485. void __fastcall TOpenDirectoryDialog::SetMode(TOpenDirectoryMode value)
  486. {
  487. FMode = value;
  488. Caption = LoadStr(Mode == odBrowse ?
  489. OPEN_DIRECTORY_BROWSE_CAPTION : OPEN_DIRECTORY_ADD_BOOMARK_ACTION );
  490. }
  491. //---------------------------------------------------------------------------
  492. void __fastcall TOpenDirectoryDialog::FormShow(TObject * /*Sender*/)
  493. {
  494. UpdateControls(true);
  495. if (Mode == odBrowse)
  496. {
  497. ActiveControl = CurrentEdit;
  498. }
  499. else
  500. {
  501. ActiveControl = GetBookmarksList(PageControl->ActivePage);
  502. }
  503. }
  504. //---------------------------------------------------------------------------
  505. void __fastcall TOpenDirectoryDialog::BookmarksListKeyDown(TObject * Sender,
  506. WORD & Key, TShiftState /*Shift*/)
  507. {
  508. if ((GetBookmarksList(Sender)->ItemIndex >= 0) && (Key == VK_DELETE))
  509. {
  510. RemoveBookmark(Sender);
  511. }
  512. }
  513. //---------------------------------------------------------------------------
  514. void __fastcall TOpenDirectoryDialog::LocalDirectoryBrowseButtonClick(
  515. TObject * /*Sender*/)
  516. {
  517. UnicodeString Directory = LocalDirectoryEdit->Text;
  518. if (SelectDirectory(Directory, LoadStr(SELECT_LOCAL_DIRECTORY), true))
  519. {
  520. LocalDirectoryEdit->Text = Directory;
  521. DirectoryEditChange(NULL);
  522. }
  523. }
  524. //---------------------------------------------------------------------------
  525. void __fastcall TOpenDirectoryDialog::SwitchButtonClick(TObject * /*Sender*/)
  526. {
  527. WinConfiguration->UseLocationProfiles = true;
  528. }
  529. //---------------------------------------------------------------------------
  530. void __fastcall TOpenDirectoryDialog::HelpButtonClick(TObject * /*Sender*/)
  531. {
  532. FormHelp(this);
  533. }
  534. //---------------------------------------------------------------------------
  535. void __fastcall TOpenDirectoryDialog::BookmarksListEndDrag(TObject * Sender,
  536. TObject * /*Target*/, int /*X*/, int /*Y*/)
  537. {
  538. GetScrollOnDragOver(Sender)->EndDrag();
  539. }
  540. //---------------------------------------------------------------------------
  541. void __fastcall TOpenDirectoryDialog::ShortCutBookmarkButtonClick(
  542. TObject * Sender)
  543. {
  544. TBookmarkList * BookmarkList = GetBookmarkList(Sender);
  545. TListBox * BookmarksList = GetBookmarksList(Sender);
  546. int Index = BookmarksList->ItemIndex;
  547. TBookmark * Bookmark = GetBookmark(BookmarksList, Index);
  548. assert(Bookmark != NULL);
  549. TShortCuts ShortCuts;
  550. WinConfiguration->CustomCommandList->ShortCuts(ShortCuts);
  551. BookmarkList->ShortCuts(ShortCuts);
  552. TShortCut ShortCut = Bookmark->ShortCut;
  553. if (DoShortCutDialog(ShortCut, ShortCuts, HelpKeyword))
  554. {
  555. Bookmark->ShortCut = ShortCut;
  556. BookmarksList->Items->Strings[Index] = BookmarkText(Bookmark);
  557. UpdateControls(true);
  558. }
  559. }
  560. //---------------------------------------------------------------------------
  561. void __fastcall TOpenDirectoryDialog::PageControlChange(TObject * /*Sender*/)
  562. {
  563. BookmarkSelected(GetBookmarksList(PageControl->ActivePage));
  564. }
  565. //---------------------------------------------------------------------------