예제 #1
0
        public TabView()
        {
            InitializeComponent();

            Style = this.FindResource("TabViewStyle") as Style;

            if (TabState == null)
            {
                TabState = new TabUIState();
            }

            this.Page_showhide.MouseLeftButtonUp     += ShowHidePagePane;
            this.Explorer_showhide.MouseLeftButtonUp += ShowHideExplorerPane;
            this.Bookview_showhide.MouseLeftButtonUp += ShowHideBookviewPane;

            this.CloseExplorerPanel.Click += CloseExplorerPanel_Clicked;


            this.ExplorerGridSplitter.LayoutUpdated += ExplorerGridSplitter_LayoutUpdated;
            this.CentralGridSplitter.LayoutUpdated  += CentralGridSplitter_LayoutUpdated;
            this.PageGridSplitter.LayoutUpdated     += PageGridSplitter_LayoutUpdated;
            this.PageGridSplitter.DragDelta         += PageGridSplitter_DragDelta;
            this.PageGridSplitter.DragCompleted     += PageGridSplitter_DragCompleted;
            this.LayoutUpdated += OnLayoutUpdated;
        }
예제 #2
0
        private void ShowHideBookviewPane(object sender, MouseButtonEventArgs e)
        {
            _bookVisible = !_bookVisible;
            if (!_bookVisible)
            {
                Bookview_showhide.Source             = bookview_show;
                this.BookPane_Height.Height          = _gridLengthZero;
                this.BookPane_Splitter_Height.Height = _gridLengthZero;
            }
            else
            {
                Bookview_showhide.Source             = bookview_show;
                this.BookPane_Height.Height          = _book_height;
                this.BookPane_Splitter_Height.Height = _gridLengthSplitters;
            }
            TabUIState state = TabState;

            state.bookViewVisible = _bookVisible;
            state.doLoad          = false;
            TabState = state;
            if (BookVisible != _bookVisible)
            {
                BookVisible = _bookVisible;
            }
        }
예제 #3
0
        private void ShowHideExplorerPane(object sender, MouseButtonEventArgs e)
        {
            _explorerVisible = !_explorerVisible;
            if (!_explorerVisible)
            {
                Explorer_showhide.Source               = leftpanel_show;
                this.ExplorerPane_Width.Width          = _gridLengthZero;
                this.ExplorerPane_Splitter_Width.Width = _gridLengthZero;
            }
            else
            {
                Explorer_showhide.Source               = leftpanel_hide;
                this.ExplorerPane_Width.Width          = _explorer_width;
                this.ExplorerPane_Splitter_Width.Width = _gridLengthSplitters;
            }

            TabUIState state = TabState;

            state.explorerVisible = _explorerVisible;
            state.doLoad          = false;
            TabState = state;
            if (ExplorerVisible != _explorerVisible)
            {
                ExplorerVisible = _explorerVisible;
            }
        }
예제 #4
0
 private void CentralGridSplitter_LayoutUpdated(object sender, EventArgs e)
 {
     _library_height = LibraryPane_Height.Height;
     if (_bookVisible)
     {
         _book_height = BookPane_Height.Height;
         double     h     = _library_height.Value + _book_height.Value;
         double     rel   = _book_height.Value / h;
         GridLength gl    = new GridLength(rel, GridUnitType.Star);
         TabUIState state = TabState;
         state.bookview = new SerializableGridLength(gl);
         state.doLoad   = false;
         TabState       = state;
     }
 }
예제 #5
0
 private void ExplorerGridSplitter_LayoutUpdated(object sender, EventArgs e)
 {
     _library_width = LibraryPane_Width.Width;
     if (_explorerVisible)
     {
         _explorer_width = this.ExplorerPane_Width.Width;
         double     w     = _library_width.Value + _explorer_width.Value;
         double     rel   = _explorer_width.Value / w;
         GridLength gl    = new GridLength(rel, GridUnitType.Star);
         TabUIState state = TabState;
         state.explorer = new SerializableGridLength(gl);
         state.doLoad   = false;
         TabState       = state;
     }
 }
예제 #6
0
 private void PageGridSplitter_LayoutUpdated(object sender, EventArgs e)
 {
     _nav_width = Navpane_Width.Width;
     if (_pageVisible)
     {
         _page_width = PagePane_Width.Width;
         double     w     = _nav_width.Value + _page_width.Value;
         double     rel   = _page_width.Value / w;
         GridLength gl    = new GridLength(rel, GridUnitType.Star);
         TabUIState state = TabState;
         state.page   = new SerializableGridLength(gl);
         state.doLoad = false;
         TabState     = state;
     }
 }
예제 #7
0
        private void ShowHidePagePane(object sender, MouseButtonEventArgs e)
        {
            _pageVisible = !_pageVisible;
            if (_pageVisible)
            {
                Page_showhide.Source          = leftpanel_hide;
                PagePane_Width.Width          = _page_width;
                PagePane_Splitter_Width.Width = _gridLengthSplitters;
            }
            else
            {
                Page_showhide.Source          = leftpanel_show;
                PagePane_Width.Width          = _gridLengthZero;
                PagePane_Splitter_Width.Width = _gridLengthZero;
            }
            TabUIState state = TabState;

            state.pageVisible = _pageVisible;
            state.doLoad      = false;
            TabState          = state;
        }
예제 #8
0
        public TabViewModel(ShellViewModel conductor, BblTabState tabstate, ObservableCollection <TabOptions> savedOptions)
        {
            _conductor  = conductor;
            _tabState   = tabstate;
            Library     = new LibraryViewModel(this);
            DisplayName = tabstate.displayName;

            TabUIState uistate = tabstate.uiState;

            uistate.doLoad = true;
            TabUIState     = uistate;
            _savedOptions  = savedOptions;

            if (string.IsNullOrEmpty(tabstate.windowedOptions))
            {
                tabstate.windowedOptions = "default";
            }
            if (string.IsNullOrEmpty(tabstate.fullscreenOptions))
            {
                tabstate.fullscreenOptions = "default";
            }

            foreach (var o in savedOptions)
            {
                if (tabstate.windowedOptions == o.Name)
                {
                    WindowedOptions = o;
                }
                else if (tabstate.fullscreenOptions == o.Name)
                {
                    FullscreenOptions = o;
                }
            }

            TheExplorer = new XamlFSExplorer.FSExplorer(new DirectoryInfoEx[] { FSExplorer.MyComputerDirectory })
            {
                HideAttributes = FileAttributes.Hidden | FileAttributes.System | FileAttributes.Offline,
                ShowDisabled   = true
            };
            var bookmark = _tabState.currentBookmark;

            bookmark.destroyOnClose = true;
            var fsbm = TheExplorer.AddBookmark(bookmark);

            fsbm.BookmarkClicked += GotoBookmark;
            fsbm.BookmarkDeleted += OnBookmarkDeleted;
            _bookmarks.Add(fsbm);

            foreach (var bm in _tabState.savedBookmarks)
            {
                fsbm = TheExplorer.AddBookmark(bm);
                fsbm.BookmarkClicked += GotoBookmark;
                fsbm.BookmarkDeleted += OnBookmarkDeleted;
                _bookmarks.Add(fsbm);
            }
            _tabState.savedBookmarks.Clear();

            _customSorts.Add(new CustomSort("Natural"));
            _customSorts.Add(new CustomSort("Path"));
            _customSorts.Add(new CustomSort("Name"));
            _customSorts.Add(new CustomSort("Creation Time"));
            _customSorts.Add(new CustomSort("Last Modified"));
            _customSorts.Add(new CustomSort("Randomized"));

            if (string.IsNullOrEmpty(_tabState.booksSort))
            {
                _tabState.booksSort = "Creation Time";
            }

            SelectedCustomSort = _customSorts.Where(x => x.Name == _tabState.booksSort).FirstOrDefault();
            SortDirection      = _tabState.booksSortDirection;
        }
예제 #9
0
        protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
        {
            base.OnPropertyChanged(e);
            if (e.Property.Name == "PageVisible" && (bool)e.NewValue != _pageVisible)
            {
                ShowHidePagePane(null, null);
            }
            else if (e.Property.Name == "ExplorerVisible" && (bool)e.NewValue != _explorerVisible)
            {
                ShowHideExplorerPane(null, null);
            }
            else if (e.Property.Name == "BookVisible" && (bool)e.NewValue != _bookVisible)
            {
                ShowHideBookviewPane(null, null);
            }
            else if (e.Property.Name == "TabState")
            {
                TabUIState state = e.NewValue as TabUIState;
                if (state.doLoad == true)
                {
                    _page_width = state.page.ToGridLength;
                    this.Navpane_Width.Width = _nav_width = new GridLength(1d - _page_width.Value, GridUnitType.Star);

                    _explorer_width = state.explorer.ToGridLength;
                    this.LibraryPane_Width.Width = _library_width = new GridLength(1d - _explorer_width.Value, GridUnitType.Star);

                    _book_height = state.bookview.ToGridLength;
                    this.LibraryPane_Height.Height = _library_height = new GridLength(1d - _book_height.Value, GridUnitType.Star);

                    if (state.pageVisible == true)
                    {
                        PageVisible = _pageVisible = true;
                        this.PagePane_Width.Width          = _page_width;
                        this.PagePane_Splitter_Width.Width = _gridLengthSplitters;
                        this.Page_showhide.Source          = leftpanel_show;
                    }
                    else
                    {
                        PageVisible = _pageVisible = false;
                        this.PagePane_Width.Width          = _gridLengthZero;
                        this.PagePane_Splitter_Width.Width = _gridLengthZero;
                        this.Page_showhide.Source          = leftpanel_hide;
                    }

                    if (state.explorerVisible == true)
                    {
                        ExplorerVisible = _explorerVisible = true;
                        this.ExplorerPane_Width.Width          = _explorer_width;
                        this.ExplorerPane_Splitter_Width.Width = _gridLengthSplitters;
                        this.Explorer_showhide.Source          = leftpanel_hide;
                    }
                    else
                    {
                        ExplorerVisible = _explorerVisible = false;
                        this.ExplorerPane_Width.Width          = _gridLengthZero;
                        this.ExplorerPane_Splitter_Width.Width = _gridLengthZero;
                        this.Explorer_showhide.Source          = leftpanel_show;
                    }

                    this.LibraryPane_Height.Height = new GridLength(1d - _book_height.Value, GridUnitType.Star);
                    if (state.bookViewVisible == true)
                    {
                        BookVisible = _bookVisible = true;
                        this.BookPane_Height.Height          = _book_height;
                        this.BookPane_Splitter_Height.Height = _gridLengthSplitters;
                        this.Bookview_showhide.Source        = bookview_hide;
                    }
                    else
                    {
                        BookVisible = _bookVisible = false;
                        this.BookPane_Height.Height          = _gridLengthZero;
                        this.BookPane_Splitter_Height.Height = _gridLengthZero;
                        this.Bookview_showhide.Source        = bookview_show;
                    }
                }
            }
        }