Ejemplo n.º 1
0
        public void Add(IEntryViewModel item)
        {
            _updatingNavigationHistory = true;
            try
            {
                //GC.Collect(0, GCCollectionMode.Forced, true);
                if (NavigationPosition != -1)
                {
                    for (int i = 0; i < NavigationPosition; i++)
                    {
                        NavigationHistory.RemoveAt(0);
                    }
                }
                while (NavigationHistory.Count > 10)
                {
                    NavigationHistory.RemoveAt(NavigationHistory.Count - 1);
                }

                if (NavigationHistory.IndexOf(item) != -1)
                {
                    NavigationHistory.Remove(item);
                }
                NavigationHistory.Insert(0, item);
                NavigationPosition = 0;

                UpdateState();
            }
            finally
            {
                _updatingNavigationHistory = false;
            }
        }
Ejemplo n.º 2
0
        public void AddAndBroadcast(IEntryViewModel destFolder)
        {
            //Prevent two events from publishing simultaneously.
            //if (_navigationHistory.Count > 1 && this._navigationHistory[1].Equals(destFolder) &&
            //    DateTime.UtcNow.Subtract(_lastBroadcast).TotalSeconds < 1)
            //    return;

            Add(destFolder);
            Events.PublishOnUIThread(new DirectoryChangedEvent(this, destFolder, _currentFolder));
            _currentFolder = destFolder;
            _lastBroadcast = DateTime.UtcNow;
        }
Ejemplo n.º 3
0
        protected override void OnViewAttached(object view, object context)
        {
            if (!IsViewAttached)
            {
                _sbox   = (view as UserControl).FindName("sbox") as SuggestBoxBase;
                _switch = (view as UserControl).FindName("switch") as FileExplorer.WPF.BaseControls.Switch;
                _bexp   = (view as UserControl).FindName("bexp") as DropDownList;

                _bexp.AddValueChanged(ComboBox.SelectedValueProperty, (o, e) =>
                {
                    IEntryViewModel evm = _bexp.SelectedItem as IEntryViewModel;
                    if (evm != null)
                    {
                        BroadcastDirectoryChanged(evm);
                    }

                    _switch.Dispatcher.BeginInvoke(new System.Action(() =>
                    {
                        _switch.IsSwitchOn = true;
                    }));
                });

                _switch.AddValueChanged(FileExplorer.WPF.BaseControls.Switch.IsSwitchOnProperty, (o, e) =>
                {
                    if (!_switch.IsSwitchOn)
                    {
                        _sbox.Dispatcher.BeginInvoke(new System.Action(() =>
                        {
                            Keyboard.Focus(_sbox);
                            _sbox.Focus();
                            _sbox.SelectAll();
                        }), System.Windows.Threading.DispatcherPriority.Background);
                    }
                });


                var uiEle = view as System.Windows.UIElement;
                this.Commands.RegisterCommand(uiEle, ScriptBindingScope.Local);
            }
            base.OnViewAttached(view, context);
            //_sbox.AddHandler(TextBlock.LostFocusEvent, (RoutedEventHandler)((s, e) =>
            //{
            //    if (!_switch.IsSwitchOn)
            //    {
            //        _switch.Dispatcher.BeginInvoke(new System.Action(() =>
            //            {
            //                _switch.IsSwitchOn = true;
            //            }));
            //    }

            //}));
        }
Ejemplo n.º 4
0
 private PropertiesViewModel(IEntryViewModel entryViewModel)
 {
     //Title = string.Format((string)Application.Current.Resources["PropertiesOf"], entryViewModel.Label);
     Icon = entryViewModel.Icon;
 }
Ejemplo n.º 5
0
 public DirectoryChangedEvent(object sender, IEntryViewModel newVM, IEntryViewModel originalVM)
     : base(sender)
 {
     NewViewModel      = newVM;
     OriginalViewModel = originalVM;
 }
 public EntryViewModelCommands(IEntryViewModel entryViewModel, IFileSystem fileSystem)
 {
     _entryViewModel = entryViewModel;
     _fileSystem     = fileSystem;
 }
 protected void BroadcastDirectoryChanged(IEntryViewModel viewModel)
 {
     _events.PublishOnUIThread(new SelectionChangedEvent(this, new IEntryViewModel[] { viewModel }));
 }
Ejemplo n.º 8
0
 public static bool IsDirectory(this IEntryViewModel entryViewModel)
 {
     return(entryViewModel.EntryType == EntryType.Directory);
 }
Ejemplo n.º 9
0
 public static bool IsFileSystemEntry(this IEntryViewModel entryViewModel)
 {
     return(entryViewModel.EntryType == EntryType.File || entryViewModel.EntryType == EntryType.Directory);
 }
Ejemplo n.º 10
0
 public bool Equals(IEntryViewModel other)
 {
     return(Equals((object)other));
 }