Exemple #1
0
 private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     ItemsSource = e.NewValue as FileCollectionBase;
     if (ItemsSource != null)
     {
         itemAdd.CommandParameter = new ItemParams(ObjectType.File, ItemsSource.OwnerId);
     }
 }
Exemple #2
0
        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();
            }
        }
Exemple #3
0
        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();
        }
Exemple #4
0
        private bool action_enter()
        {
            if (Source == null)
            {
                return(true);
            }

            //if not container, do default action of Source
            if (!Source.GetItemIsContainer(inner_ListControl.FocusedIndex))
            {
                Source.DefautlAction(FocusedIndex, false);
                return(true);
            }

            //try to get child collection
            //FileCollectionBase new_source = Source.GetChildCollection(inner_ListControl.FocusedIndex,ref preferred_focus_name);
            inner_ListControl.ClearSelection(false);
            FileCollectionBase new_source = null;
            var use_new = false;

            Source.GetChildCollection(inner_ListControl.FocusedIndex, ref new_source, ref use_new, ref preferred_focus_name);

            if (use_new)
            {
                //refilling MUST be already done in GetChildCollection
                //source completely new
                if (new_source == null)
                {
                    return(false);
                }
                //change Source
                Source = new_source;
                internal_source_AfterRefill(Source, new EventArgs());
            }


            //if use_new==false
            //Refill() must be call from FileCollectionBase
            //Source.Refill();

            //return true - supress subsequent key processing
            return(true);
        }