Пример #1
0
        void DuplicateTab()
        {
            if (!tabControlManager.CanExcectute())
            {
                return;
            }

            var CurrentTab = tabControlManager.CurrentTab;
            var Filepath   = CurrentTab.Path;

            if (string.IsNullOrEmpty(Filepath))
            {
                var fileDialog = new OpenFileDialog
                {
                    Multiselect  = true,
                    AddExtension = true,
                    Filter       = FileFormats.FilterString
                };
                fileDialog.ShowDialog();
                Filepath = fileDialog.FileName;
            }

            if (!FilesManager.ValidFile(Filepath))
            {
                return;
            }

            var duplicate_tab     = tabControlManager.CurrentTab;
            var currentTabControl = tabControlManager.CurrentTabControl;

            if (currentTabControl.SelectedIndex != -1)
            {
                TabablzControl.AddItem(TabControlManager.GetTab(Filepath), duplicate_tab, AddLocationHint.After);
                currentTabControl.SelectedIndex = currentTabControl.Items.Count - 1;
            }
            else
            {
                var addedTab = tabControlManager.AddTab(Filepath);
                addedTab.ImageSettings.PropertyChanged += ImageSettings_PropertyChanged;
            }

            duplicate_tab = tabControlManager.CurrentTab;
            duplicate_tab.InitialImagePath         = Filepath;
            duplicate_tab.Footer.Visibility        = footerVisibility;
            duplicate_tab.ImageSettings.SortMethod = CurrentTab.ImageSettings.SortMethod;
            duplicate_tab.ImageSettings.SortMode   = CurrentTab.ImageSettings.SortMode;

            filesManager.SupportedFiles(Path.GetDirectoryName(Filepath));

            var FilenameIndex =
                duplicate_tab.Paths.FindIndex(x => Path.GetFileName(x) == Path.GetFileName(Filepath));

            duplicate_tab.Index = FilenameIndex == -1 ? 0 : (uint)FilenameIndex;

            DisplayImage();
            SetupDirectoryWatcher();
        }
Пример #2
0
        public MainWindow()
        {
            AutoUpdater.ShowSkipButton = false;

            InitializeComponent();

            tabControlManager = new TabControlManager(ImageTabControl);
            sortingManager    = new SortingManager(tabControlManager);
            filesManager      = new FilesManager(sortingManager, tabControlManager);

            CheckForUpdates();
            SetupSlideshow();

            commands = new Dictionary <CommandKeys, ICommand>
            {
                {
                    new CommandKeys(Key.A),
                    new ToggleDisplayChannelCommand(ToggleDisplayChannel, Channels.Alpha, tabControlManager.CanExcectute)
                },
                {
                    new CommandKeys(Key.R),
                    new ToggleDisplayChannelCommand(ToggleDisplayChannel, Channels.Red, tabControlManager.CanExcectute)
                },
                {
                    new CommandKeys(Key.G),
                    new ToggleDisplayChannelCommand(ToggleDisplayChannel, Channels.Green, tabControlManager.CanExcectute)
                },
                {
                    new CommandKeys(Key.B),
                    new ToggleDisplayChannelCommand(ToggleDisplayChannel, Channels.Blue, tabControlManager.CanExcectute)
                },
                { new CommandKeys(Key.F), new Command(ResetView, tabControlManager.CanExcectute) },
                { new CommandKeys(Key.T), new Command(TileImage, tabControlManager.CanExcectute) },
                { new CommandKeys(Key.Space), new Command(NextImage, tabControlManager.CanExcectute) },
                { new CommandKeys(Key.Delete), new Command(DeleteImage, tabControlManager.CanExcectute) },
                { new CommandKeys(Key.D, Key.LeftCtrl), new Command(DuplicateTab, tabControlManager.CanExcectute) },
                {
                    new CommandKeys(Key.W, Key.LeftCtrl),
                    new Command(tabControlManager.CloseSelectedTab, tabControlManager.CanExcectute)
                },
                { new CommandKeys(Key.S, Key.LeftCtrl), new Command(ChannelsMontage, tabControlManager.CanExcectute) },
                { new CommandKeys(Key.S), new Command(ToggleSlideshow, tabControlManager.CanExcectute) },
                { new CommandKeys(Key.Right, Key.LeftCtrl), new Command(NextTab, tabControlManager.CanExcectute) },
                { new CommandKeys(Key.Left, Key.LeftCtrl), new Command(PreviousTab, tabControlManager.CanExcectute) },
                { new CommandKeys(Key.Right), new Command(NextImage, tabControlManager.CanExcectute) },
                { new CommandKeys(Key.Left), new Command(PreviousImage, tabControlManager.CanExcectute) },
                { new CommandKeys(Key.Add), new Command(LowerMip, tabControlManager.CanExcectute) },
                { new CommandKeys(Key.Subtract), new Command(HigherMip, tabControlManager.CanExcectute) },
                { new CommandKeys(Key.Space, Key.LeftCtrl), new Command(ToggleBars, tabControlManager.CanExcectute) },
                { new CommandKeys(Key.V, Key.LeftCtrl), new Command(Paste) },
                { new CommandKeys(Key.C, Key.LeftCtrl), new Command(Copy, tabControlManager.CanExcectute) },
                { new CommandKeys(Key.Escape), new Command(Close) },
                { new CommandKeys(Key.N, Key.LeftCtrl), new Command(AddNewTab) },
            };
        }
Пример #3
0
        void DockLayoutDragDrop(object sender, DragEventArgs e)
        {
            //var bitmap = e.Data.GetData(DataFormats.Bitmap);
            //var html = e.Data.GetData(DataFormats.Html);
            var filenames = (string[])e.Data.GetData(DataFormats.FileDrop, false);

            if (filenames == null)
            {
                return;
            }

            if (e.OriginalSource is DependencyObject current)
            {
                while (!(VisualTreeHelper.GetParent(current) is TabablzControl))
                {
                    current = VisualTreeHelper.GetParent(current);
                }

                var tabablzControl = VisualTreeHelper.GetParent(current) as TabablzControl;
                (tabablzControl?.SelectedItem as TabItemControl)?.ImagePresenter.ScrollViewer.Focus();
            }

            var supportedFilenames = FilesManager.FilterSupportedFiles(filenames);

            if (supportedFilenames.Length == 0)
            {
                return;
            }

            if (supportedFilenames.Length > 1)
            {
                Parallel.ForEach(supportedFilenames, AddNewTab);
            }
            else
            {
                if (Settings.Default.ReplaceImageOnDrop)
                {
                    ReplaceImageInTab(supportedFilenames[0]);
                }
                else
                {
                    AddNewTab(supportedFilenames[0]);
                }
            }

            Keyboard.Focus(this);

            e.Handled = true;
        }
Пример #4
0
        public void AddNewTab(string filepath)
        {
            if (string.IsNullOrEmpty(filepath))
            {
                var fileDialog = new OpenFileDialog
                {
                    Multiselect  = true,
                    AddExtension = true,
                    Filter       = FileFormats.FilterString
                };
                fileDialog.ShowDialog();
                filepath = fileDialog.FileName;
            }

            if (!FilesManager.ValidFile(filepath))
            {
                return;
            }

            var CurrentTab        = tabControlManager.CurrentTab;
            var CurrentTabControl = tabControlManager.CurrentTabControl;

            if (CurrentTabControl.SelectedIndex != -1)
            {
                TabablzControl.AddItem(TabControlManager.GetTab(filepath), CurrentTab, AddLocationHint.After);
                CurrentTabControl.SelectedIndex = CurrentTabControl.Items.Count - 1;
            }
            else
            {
                var AddedTab = tabControlManager.AddTab(filepath);
                AddedTab.ImageSettings.PropertyChanged += ImageSettings_PropertyChanged;
            }

            CurrentTab = tabControlManager.CurrentTab;

            filesManager.SupportedFiles(Path.GetDirectoryName(filepath));

            var FilenameIndex =
                CurrentTab.Paths.FindIndex(x => Path.GetFileName(x) == Path.GetFileName(filepath));

            CurrentTab.Index = FilenameIndex == -1 ? 0 : (uint)FilenameIndex;

            CurrentTab.Footer.Visibility = footerVisibility;

            SetupDirectoryWatcher();
        }
Пример #5
0
        void Paste()
        {
            if (Clipboard.ContainsFileDropList())
            {
                var filenames = new List <string>();

                Parallel.ForEach(Clipboard.GetFileDropList().Cast <string>(), filepath =>
                {
                    filenames.Add(filepath);
                });

                var supportedFilenames = FilesManager.FilterSupportedFiles(filenames.ToArray());
                if (supportedFilenames.Length > 0)
                {
                    Parallel.ForEach(supportedFilenames, AddNewTab);
                }
            }
        }
Пример #6
0
        void ReplaceImageInTab(string filename)
        {
            if (!FilesManager.ValidFile(filename))
            {
                return;
            }

            if (tabControlManager.CurrentTabIndex < 0)
            {
                AddNewTab(filename);
            }
            else
            {
                var CurrentTab = tabControlManager.CurrentTab;
                CurrentTab.InitialImagePath = filename;
                filesManager.SupportedFiles(Path.GetDirectoryName(filename));

                var Index = CurrentTab.Paths.IndexOf(filename);
                CurrentTab.Index = Index == -1 ? 0 : (uint)Index;
                SetupDirectoryWatcher();
            }
        }