void cmd_SetNewSource(object sender, SetNewSourceEventArgs e) { if (e.NewSource == null) { return; } Source = e.NewSource; preferred_focus_name = e.PreferredFocusText; if (e.ForceRefillLater) { Source.Refill(); } else { //update without refill inner_ListControl.UpdateEnable = false; //we need update FocusedIndex if (e.NewSource.ItemCount == 0) { inner_ListControl.FocusedIndex = -1; } else { //preferred_focus_name we set upper if (preferred_focus_name == string.Empty) { inner_ListControl.FocusedIndex = 0; } else { var preferred_focus = Source.FindIndexOfName(preferred_focus_name); if (preferred_focus == -1) { inner_ListControl.FocusedIndex = 0; } else { inner_ListControl.FocusedIndex = preferred_focus; } } } inner_ListControl.UpdateEnable = true; inner_ListControl.UpdateAllItems(true); inner_InfoPanel.RefreshSafe(); inner_ListControl.ScrollToFocusVisible(); OnStatusTextChanged(); } }
void internal_source_AfterRefill(object sender, EventArgs e) { inner_ListControl.UpdateEnable = false; //we need update FocusedIndex FileCollectionBase src = (FileCollectionBase)sender; if (src.ItemCount == 0) { inner_ListControl.FocusedIndex = -1; } else { //preferred_focus_name we get at GetChildCollection call if (preferred_focus_name == string.Empty) { inner_ListControl.FocusedIndex = 0; // need DEBUG // иначе при запуске программы курсор получается за пределами окна inner_ListControl.ScrollToFocusVisible(); // } else { int preferred_focus = src.FindIndexOfName(preferred_focus_name); if (preferred_focus == -1) { inner_ListControl.FocusedIndex = 0; } else { inner_ListControl.FocusedIndex = preferred_focus; } } } //added later inner_ListControl.ClearSelection(); inner_ListControl.UpdateEnable = true; inner_ListControl.UpdateAllItems(true); inner_InfoPanel.RefreshSafe(); inner_ListControl.ScrollToFocusVisible(); OnStatusTextChanged(); }