Exemplo n.º 1
0
        public void Execute(object parameter)
        {
            if (!(_workspace.CurrentItem is FileItem item))
            {
                return;
            }

            var    searchLister = KexContainer.Resolve <SearchLister>();
            string target;

            if (item.IsLink())
            {
                target = new FileItemTargetResolver(item).TargetPath;
            }
            else if (item.ItemType == ItemType.Item)
            {
                target = _workspace.ActiveLister.Path;
            }
            else
            {
                target = item.Path;
            }

            searchLister.Path          = target;
            searchLister.SearchPattern = "";
            searchLister.MaxItems      = 20;
            _workspace.Open(searchLister);
            searchLister.GotView += SearchLister_GotView;
        }
Exemplo n.º 2
0
        public async void Execute(object parameter)
        {
            var searchPattern = parameter as string;

            if (string.IsNullOrEmpty(searchPattern))
            {
                _workspace.NotificationHost.AddError("Please enter Searchterm");
                return;
            }

            if (_workspace.ActiveLister is SearchLister searchLister)
            {
                searchLister.SearchPattern = (string)parameter;
                if (searchLister.View != null)
                {
                    await searchLister.Refresh().ConfigureAwait(false);
                }
                else
                {
                    searchLister.GotView += searchLister_GotView;
                }
            }
            else
            {
                searchLister               = KexContainer.Resolve <SearchLister>();
                searchLister.Path          = _workspace.ActiveLister.Path;
                searchLister.SearchPattern = searchPattern;
                searchLister.GotView      += searchLister_GotView;
                _workspace.Open(searchLister);
            }
        }
Exemplo n.º 3
0
        private void SelectListers()
        {
            if (Binding == null)
            {
                return;
            }

            _selectListers = true;
            Text           = "";
            Title          = "Choose Target Lister";
            var allListers = KexContainer.ResolveMany <ILister>()
                             .Where(l => !string.IsNullOrEmpty(l.Title))
                             .Where(l => l.ShowInMenu).Select(l => new BaseItem(l.Title)
            {
                Path = l.GetType().Name
            });

            var items = new[] { new BaseItem("All")
                                {
                                    Path = null
                                } }.Concat(allListers).ToList();

            BaseItems = items;
            var index = items.FindIndex(i => i.Path == SourceBinding?.Group);

            ItemsView.MoveCurrentToPosition(index);
        }
Exemplo n.º 4
0
        public void Execute(object parameter)
        {
            var parameters = parameter as string;

            if (string.IsNullOrEmpty(parameters))
            {
                return;
            }

            var command = parameters;

            if (_workspace.ActiveLister is ConsoleLister fromLister)
            {
                fromLister.Command = command;
                fromLister.Refresh();
            }
            else
            {
                var console = KexContainer.Resolve <ConsoleLister>();
                if (_workspace.ActiveLister is FileLister fileLister)
                {
                    console.WorkingDirectory = _workspace.ActiveLister.Path;
                    console.Selection        = fileLister.SelectedItems;
                }

                console.Command = command;
                _workspace.Open(console);
                console.GotView += l => console.Refresh();
            }
        }
Exemplo n.º 5
0
        public void Register()
        {
            var kexFocus      = (Key)Enum.Parse(typeof(Key), _options.GlobalHotKey);
            var showClipboard = (Key)Enum.Parse(typeof(Key), _options.ViewClipboardHotKey);

            try
            {
                HotkeyManager.Current.AddOrReplace("FocusWindows", kexFocus, ModifierKeys.Windows, (n, h) =>
                {
                    _mainWindow.Activate();
                    _mainWindow.WindowState = WindowState.Normal;
                    _workspace.FocusListView();
                });
                HotkeyManager.Current.AddOrReplace("ViewClipboard", showClipboard, ModifierKeys.Windows, async(n, h) =>
                {
                    var textLister = KexContainer.Resolve <TextLister>();
                    _workspace.Open(textLister);
                    textLister.Path = textLister.PathName = textLister.Title = "Clipboard";
                    textLister.Text = Clipboard.GetText();
                    await textLister.Refresh();
                    _mainWindow.Activate();
                    _mainWindow.WindowState = WindowState.Normal;
                });
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);
            }
        }
Exemplo n.º 6
0
        public async void Execute(object parameter)
        {
            var lister = KexContainer.Resolve <KeyCommandsLister>();

            _workspace.Open(lister);
            await lister.Refresh().ConfigureAwait(false);
        }
Exemplo n.º 7
0
        protected override async void ItemSelected(DriveItem selectedItem)
        {
            if (selectedItem == null)
            {
                return;
            }
            if (!selectedItem.IsReady)
            {
                Workspace.NotificationHost.AddError(string.Format("Drive {0} ist not ready", selectedItem.DriveLetter));
                return;
            }

            IsOpen = false;
            if (Workspace.ActiveLister is FileLister)
            {
                Workspace.ActiveLister.Path = selectedItem.Path;
                await Workspace.ActiveLister.Refresh();
            }
            else
            {
                var lister = KexContainer.Resolve <FileLister>();
                Workspace.Open(lister);
                await lister.Refresh();
            }

            base.ItemSelected(selectedItem);
        }
Exemplo n.º 8
0
        public async void Execute(object parameter)
        {
            var notifications = KexContainer.Resolve <NotificationLister>();

            _workspace.Open(notifications);
            await notifications.Refresh().ConfigureAwait(false);
        }
Exemplo n.º 9
0
        public async void Execute(object parameter)
        {
            var network = KexContainer.Resolve <NetworkLister>();

            _workspace.Open(network);
            await network.Refresh().ConfigureAwait(false);
        }
Exemplo n.º 10
0
        public async void Execute(object parameter)
        {
            var settingsLister = KexContainer.Resolve <SettingsLister>();

            _workspace.Open(settingsLister);
            await settingsLister.Refresh().ConfigureAwait(false);
        }
Exemplo n.º 11
0
        public void Execute(object parameter)
        {
            var drives = KexContainer.Resolve <DriveLister>();

            _workspace.ReplaceCurrentLister(drives);
            _workspace.ActiveLister.Refresh();
        }
Exemplo n.º 12
0
        private async void OpenFavorites()
        {
            var fileLister = KexContainer.Resolve <FileLister>();

            fileLister.Path = Environment.GetFolderPath(Environment.SpecialFolder.Favorites);
            Workspace.Open(fileLister);
            await fileLister.Refresh().ConfigureAwait(false);
        }
Exemplo n.º 13
0
        public override async void DoAction(NetworkItem item)
        {
            var lister = KexContainer.Resolve <FileLister>();

            lister.Path = @"\\" + item.DisplayName;
            Workspace.ReplaceCurrentLister(lister);
            await lister.Refresh();
        }
Exemplo n.º 14
0
        public override async void DoAction(DriveItem item)
        {
            var fi = KexContainer.Resolve <FileLister>();

            fi.Path = item?.Path;
            Workspace.ReplaceCurrentLister(fi);
            await fi.Refresh().ConfigureAwait(false);
        }
Exemplo n.º 15
0
        public void Execute(object parameter)
        {
            var viewer = KexContainer.Resolve <ViewFileLister>();

            viewer.Path = _workspace.CurrentItem.Path;
            _workspace.Open(viewer);
            _workspace.ActiveLister.Refresh();
        }
Exemplo n.º 16
0
 public async void Execute(object parameter)
 {
     if (_workspace.CurrentItem is FileItem fileItem)
     {
         var processLister = KexContainer.Resolve <ProcessLister>();
         _workspace.Open(processLister);
         await processLister.Refresh().ConfigureAwait(false);
     }
 }
Exemplo n.º 17
0
 public async void Execute(object parameter)
 {
     if (_workspace.CurrentItem is FileItem fileItem)
     {
         var referenceLister = KexContainer.Resolve <ReferenceLister>();
         referenceLister.Path = fileItem.GetPathResolved();
         _workspace.Open(referenceLister);
         await referenceLister.Refresh().ConfigureAwait(false);
     }
 }
Exemplo n.º 18
0
        public async void Execute(object parameter)
        {
            var favoriteLocation = Environment.GetFolderPath(Environment.SpecialFolder.Favorites);
            var fileLister       = KexContainer.Resolve <FileLister>();

            fileLister.Path = favoriteLocation;
            await fileLister.Refresh();

            _workspace.Open(fileLister);
        }
Exemplo n.º 19
0
 public void Execute(object parameter)
 {
     if (_workspace.CurrentItem is FileItem fileItem)
     {
         var securityLister = KexContainer.Resolve <SecurityLister>();
         securityLister.Path = fileItem.Path;
         _workspace.Open(securityLister);
         _workspace.ActiveLister.Refresh();
     }
 }
Exemplo n.º 20
0
        private async void OpenFileLister(ProcessItem item)
        {
            var fileLister = KexContainer.Resolve <FileLister>();

            fileLister.Path = System.IO.Path.GetDirectoryName(item.FileName);
            await fileLister.Refresh();

            _processItem        = item;
            fileLister.GotView += FileLister_GotView;
            Workspace.Open(fileLister);
        }
Exemplo n.º 21
0
        public void Execute(object parameter)
        {
            if (!(_workspace.ActiveLister is FileLister))
            {
                var l = KexContainer.Resolve <FileLister>();
                _workspace.ReplaceCurrentLister(l);
            }
            var favoriteLocation = Environment.GetFolderPath(Environment.SpecialFolder.Favorites);

            _workspace.ActiveLister.Path = favoriteLocation;
            _workspace.ActiveLister.Refresh();
        }
Exemplo n.º 22
0
        private async Task ShowFileContent(FileItem fileItem)
        {
            if (_viewFileLister == null) //TODO: Inject
            {
                _viewFileLister = KexContainer.Resolve <ViewFileLister>();
            }

            var targetResolver = new FileItemTargetResolver(fileItem);

            _viewFileLister.Path = targetResolver.TargetPath;

            await _viewFileLister.Refresh().ConfigureAwait(false);

            Items = _viewFileLister.Items;
        }
Exemplo n.º 23
0
        private void App_Startup(object sender, StartupEventArgs e)
        {
            Assembly.Load("Kexi.Extensions");
            _workspace = KexContainer.Resolve <Workspace>();

            var mainWindow = new MainWindow(_workspace);

            _workspace.DockingMananger    = new DockingSerializer(_workspace, mainWindow.DockManager.DockingManager);
            DispatcherUnhandledException += App_DispatcherUnhandledException;
            mainWindow.Show();
            if (!_workspace.Options.IsInitialized)
            {
                new ShowSetupWindowCommand(_workspace).Execute(null);
            }
        }
Exemplo n.º 24
0
        public async void Execute(object parameter)
        {
            if (!(_workspace.CurrentItem is FileItem currentFileItem))
            {
                return;
            }

            var fileLister = KexContainer.Resolve <FileLister>();

            if (currentFileItem.TargetType() == ItemType.Item)
            {
                var path = currentFileItem.GetPathResolved();
                fileLister.Path = Path.GetDirectoryName(path) ?? path;
            }
            else
            {
                var path = currentFileItem.GetPathResolved();
                fileLister.Path = path;
            }

            _workspace.Open(fileLister);
            await fileLister.Refresh().ConfigureAwait(false);
        }
Exemplo n.º 25
0
        private MenuCommandBoundItem[] MenuCommandBoundItems(BitmapSource menuImg)
        {
            var items = new[]
            {
                new MenuCommandBoundItem("View", null)
                {
                    Items = new[]
                    {
                        new MenuCommandBoundItem("View Details",
                                                 new RelayCommand(c => CommandRepository.Execute(nameof(ViewDetailsCommand)))),
                        new MenuCommandBoundItem("View Icons",
                                                 new RelayCommand(c => CommandRepository.Execute(nameof(ViewIconsCommand)))),
                        new MenuCommandBoundItem("View Thumbnails",
                                                 new RelayCommand(c => CommandRepository.Execute(nameof(ViewThumbnailsCommand))))
                    },
                    Thumbnail = menuImg
                },
                new MenuCommandBoundItem("Layout", null)
                {
                    Items = new[]
                    {
                        new MenuCommandBoundItem("Toggle Adressbar",
                                                 new RelayCommand(c => CommandRepository.Execute(nameof(ToggleAdressbarVisibiblityCommand)))),
                        new MenuCommandBoundItem("Toggle Statusbar",
                                                 new RelayCommand(c => CommandRepository.Execute(nameof(ToggleStatusbarVisibilityCommand)))),
                        new MenuCommandBoundItem("Toggle Detailspane",
                                                 new RelayCommand(c => CommandRepository.Execute(nameof(ToggleFileDetailsVisibilityCommand)))),
                        new MenuCommandBoundItem("Toggle Treeview Pane",
                                                 new RelayCommand(c => CommandRepository.Execute(nameof(ToggleTreeViewVisibilityCommand)))),
                        new MenuCommandBoundItem("Toggle Ribbonpane",
                                                 new RelayCommand(c => CommandRepository.Execute(nameof(ToggleRibbonVisibilityCommand)))),
                        new MenuCommandBoundItem("Load Layout",
                                                 new RelayCommand(c => CommandRepository.Execute(nameof(LoadLayoutCommand)))),
                        new MenuCommandBoundItem("Save Layout",
                                                 new RelayCommand(c => CommandRepository.Execute(nameof(SaveLayoutCommand))))
                    },
                    Thumbnail = menuImg
                },
                new MenuCommandBoundItem("Window", null)
                {
                    Items = new[]
                    {
                        new MenuCommandBoundItem("Adjust Width",
                                                 new RelayCommand(c => CommandRepository.Execute(nameof(AdjustListerWidthCommand)))),
                        new MenuCommandBoundItem("Adjust Column Width",
                                                 new RelayCommand(c => CommandRepository.Execute(nameof(AdjustColumnWidth)))),
                        new MenuCommandBoundItem("Split Horizontal",
                                                 new RelayCommand(c => CommandRepository.Execute(nameof(WindowSplitHorizontalCommand)))),
                        new MenuCommandBoundItem("Split Vertical",
                                                 new RelayCommand(c => CommandRepository.Execute(nameof(WindowSplitVerticalCommand)))),
                        new MenuCommandBoundItem("Move To Next Group",
                                                 new RelayCommand(c => CommandRepository.Execute(nameof(MoveToNextTabCommand)))),
                        new MenuCommandBoundItem("Move To Previous Group",
                                                 new RelayCommand(c => CommandRepository.Execute(nameof(MoveToPreviousTabCommand)))),
                        new MenuCommandBoundItem("Maximize",
                                                 new RelayCommand(c => CommandRepository.Execute(nameof(WindowMaximizeCommand)))),
                        new MenuCommandBoundItem("Minimize",
                                                 new RelayCommand(c => CommandRepository.Execute(nameof(WindowMinimizeCommand)))),
                        new MenuCommandBoundItem("Restore",
                                                 new RelayCommand(c => CommandRepository.Execute(nameof(WindowRestoreCommand)))),
                        new MenuCommandBoundItem("Dock Left",
                                                 new RelayCommand(c => CommandRepository.Execute(nameof(WindowDockLeftCommand)))),
                        new MenuCommandBoundItem("Dock Right",
                                                 new RelayCommand(c => CommandRepository.Execute(nameof(WindowDockRightCommand)))),
                        new MenuCommandBoundItem("Center",
                                                 new RelayCommand(c => CommandRepository.Execute(nameof(WindowCenterCommand)))),
                        new MenuCommandBoundItem("Full Height",
                                                 new RelayCommand(c => CommandRepository.Execute(nameof(WindowFullHeightCommand)))),
                        new MenuCommandBoundItem("Next Monitor",
                                                 new RelayCommand(c => CommandRepository.Execute(nameof(WindowNextMonitorCommand))))
                    },
                    Thumbnail = menuImg
                },
                new MenuCommandBoundItem("Listers", null)
                {
                    //if injected in constructor: same listers/datasource for different process/services lister winodws => collection modified
                    Items = KexContainer.ResolveMany <ILister>()
                            .Where(l => !string.IsNullOrEmpty(l.Title))
                            .Where(l => l.ShowInMenu)
                            .Select(l => new MenuCommandBoundItem(l.Title, new RelayCommand(c =>
                    {
                        Workspace.Open(l);
                        l.Refresh();
                    }))),
                    Thumbnail = menuImg
                },
                new MenuCommandBoundItem("Options", new RelayCommand(c => CommandRepository.Execute(nameof(ShowSettingsListerCommand)))),
                new MenuCommandBoundItem("GroupBy", new RelayCommand(c => CommandRepository.Execute(nameof(ShowGroupByPopupCommand)))),
                new MenuCommandBoundItem("Sort", new RelayCommand(c => CommandRepository.Execute(nameof(ShowSortPopupCommand)))),
                new MenuCommandBoundItem("Toggle Hidden Items", new RelayCommand(c =>
                {
                    new ToggleHiddenItemsCommand(Workspace);
                    Workspace.ActiveLister.Refresh();
                })),
                new MenuCommandBoundItem("Refresh", new RelayCommand(c => CommandRepository.Execute(nameof(RefreshListerCommand)))),
                new MenuCommandBoundItem("Console Command", new RelayCommand(c => CommandRepository.Execute(nameof(ShowConsolePopupCommand)))),
                new MenuCommandBoundItem("Restart as Admin", new RelayCommand(c => CommandRepository.Execute(nameof(RestartAsAdminCommand)))),
                new MenuCommandBoundItem("Quit", new RelayCommand(c => CommandRepository.Execute(nameof(QuitCommand)))),
            };

            return(items);
        }
Exemplo n.º 26
0
        /// <summary>
        /// Coerce visibility
        /// </summary>
        /// <param name="dependencyObject">Dependency object</param>
        /// <param name="baseValue">Base value</param>
        /// <returns>Coerced value</returns>
        private static object CoerceVisibility(
            DependencyObject dependencyObject,
            object baseValue)
        {
            // Make sure object is a framework element
            FrameworkElement frameworkElement = dependencyObject as FrameworkElement;

            if (frameworkElement == null)
            {
                return(baseValue);
            }

            // Cast to type safe value
            Visibility visibility = (Visibility)baseValue;

            // If Visibility value hasn't change, do nothing.
            // This can happen if the Visibility property is set using data binding
            // and the binding source has changed but the new visibility value Hidden
            // hasn't changed.
            if (visibility == frameworkElement.Visibility)
            {
                return(baseValue);
            }

            // If element is not hooked by our attached property, stop here
            if (!IsHookedElement(frameworkElement))
            {
                return(baseValue);
            }

            // Update animation flag
            // If animation already started, don't restart it (otherwise, infinite loop)
            if (UpdateAnimationStartedFlag(frameworkElement))
            {
                return(baseValue);
            }



            // If we get here, it means we have to start fade in or fade out animation.
            // In any case return value of this method will be Visibility.Visible,
            // to allow the animation.
            var doubleAnimation = new DoubleAnimation
            {
                Duration = new Duration(TimeSpan.FromMilliseconds(AnimationDuration))
            };

            var thicknessAnimation = GetThicknessAnimation(visibility, frameworkElement);

            // When animation completes, set the visibility value to the requested
            // value (baseValue)
            doubleAnimation.Completed += (sender, eventArgs) =>
            {
                if (visibility == Visibility.Visible)
                {
                    // In case we change into Visibility.Visible, the correct value
                    // is already set, so just update the animation started flag
                    UpdateAnimationStartedFlag(frameworkElement);
                }
                else
                {
                    // This will trigger value coercion again
                    // but UpdateAnimationStartedFlag() function will return true
                    // this time, thus animation will not be triggered.
                    if (BindingOperations.IsDataBound(frameworkElement,
                                                      UIElement.VisibilityProperty))
                    {
                        // Set visibility using bounded value
                        Binding bindingValue =
                            BindingOperations.GetBinding(frameworkElement,
                                                         UIElement.VisibilityProperty);
                        BindingOperations.SetBinding(frameworkElement,
                                                     UIElement.VisibilityProperty, bindingValue);
                    }
                    else
                    {
                        // No binding, just assign the value
                        frameworkElement.Visibility = visibility;
                    }
                }
            };



            if (visibility == Visibility.Collapsed || visibility == Visibility.Hidden)
            {
                var workspace = KexContainer.Resolve <Workspace>();
                if (workspace.Options.PopupAnimation == PopupAnimation.None)
                {
                    return(baseValue);
                }
                // Fade out by animating opacity
                doubleAnimation.From = frameworkElement.Opacity;
                doubleAnimation.To   = 0.0;
            }
            else
            {
                // Fade in by animating opacity
                doubleAnimation.From = frameworkElement.Opacity;
                doubleAnimation.To   = 1.0;
            }

            // Start animation
            if (doubleAnimation != null)
            {
                frameworkElement.BeginAnimation(UIElement.OpacityProperty, doubleAnimation);
            }
            if (thicknessAnimation != null)
            {
                frameworkElement.BeginAnimation(FrameworkElement.MarginProperty, thicknessAnimation);
            }

            // Make sure the element remains visible during the animation
            // The original requested value will be set in the completed event of
            // the animation
            return(Visibility.Visible);
        }