/// <summary> /// Load the specifed directory with specifed content into the panel and set view options /// </summary> /// <param name="URL">The full URL of the directory (for reference needs)</param> /// <param name="dis">Directory item list</param> /// <param name="ShortenKB">How kilobyte sizes should be humanized</param> /// <param name="ShortenMB">How megabyte sizes should be humanized</param> /// <param name="ShortenGB">How gigabyte sizes should be humanized</param> //плохой перевод? "так nбайтные размеры должны очеловечиваться" public void LoadDir(string URL, List <DirItem> dis, SizeDisplayPolicy ShortenKB, SizeDisplayPolicy ShortenMB, SizeDisplayPolicy ShortenGB) { if (FS.CurrentDirectory == null) { //if this is first call in the session (the FLP is just initialized) using (Menu hm = HistoryButton.Menu) { MenuItem hmi = new MenuItem(URL); hmi.Clicked += (o, ea) => { NavigateTo(URL, (int)hmi.Tag); }; hmi.Tag = hm.Items.Count; hm.Items.Add(hmi); } } ListingView.Cursor = Xwt.CursorType.IBeam; //todo: modify XWT and add hourglass cursor ListingView.Sensitive = false; try { FS.CurrentDirectory = URL; ListingView.Clear(); UrlBox.Text = URL; FS.StatusChanged += new TypedEvent <string>(FS_StatusChanged); FS.ProgressChanged += new TypedEvent <double>(FS_ProgressChanged); string updir = URL + FS.DirSeparator + ".."; string rootdir = FS.GetMetadata(URL).RootDirectory; foreach (DirItem di in dis) { List <Object> Data = new List <Object>(); Data.Add(di.IconSmall ?? Xwt.Drawing.Image.FromResource("pluginner.Resources.image-missing.png")); Data.Add(di.Path); Data.Add(di.TextToShow); if (di.TextToShow == "..") { //parent dir Data.Add("<↑ UP>"); Data.Add(FS.GetMetadata(di.Path).LastWriteTimeUTC.ToLocalTime()); updir = di.Path; } else if (di.IsDirectory) { //dir Data.Add("<DIR>"); Data.Add(di.Date); } else { //file Data.Add(KiloMegaGigabyteConvert(di.Size, ShortenKB, ShortenMB, ShortenGB)); Data.Add(di.Date); } Data.Add(di); ListingView.AddItem(Data, di.Path); } GoUp.Clicked += (o, ea) => { LoadDir(updir); }; GoRoot.Clicked += (o, ea) => { LoadDir(rootdir); }; } catch (Exception ex) { if (ex.Message == "Object reference not set to an instance of an object.") { Xwt.MessageDialog.ShowWarning(ex.Message, ex.StackTrace + "\nInner exception: " + ex.InnerException.Message ?? "none"); } else { Xwt.MessageDialog.ShowWarning(ex.Message); } } ListingView.Sensitive = true; ListingView.Cursor = Xwt.CursorType.Arrow; if (ListingView.Items.Count > 0) { ListingView.SelectedRow = 0; ListingView.ScrollerIn.ScrollTo(0, 0); } ListingView.SetFocus(); //one fixed bug may make many other bugs...уточнить необходимость! }