Bläddra i källkod

多窗口-修复多窗口页签问题

ZhouJieSheng 2 år sedan
förälder
incheckning
fe84b5eb96

+ 19 - 0
PDF Office/App.xaml.cs

@@ -6,13 +6,17 @@ using System.IO;
 using System.Linq;
 using System.Threading.Tasks;
 using System.Windows;
+using System.Windows.Controls;
 using ComPDFKit.NativeMethod;
 using ComPDFKit_Conversion.Converter;
+using PDF_Office.CustomControl;
 using PDF_Office.ViewModels;
 using PDF_Office.Views;
+using PDF_Office.Views.BOTA;
 using PDF_Office.Views.HomePanel;
 using Prism.DryIoc;
 using Prism.Ioc;
+using Prism.Regions;
 
 namespace PDF_Office
 {
@@ -25,6 +29,8 @@ namespace PDF_Office
 
         public static List<string> OpenedFileList = new List<string>();
 
+        public static bool IsFirstOpen = true;
+
         public App()
         {
 
@@ -46,6 +52,7 @@ namespace PDF_Office
         /// <returns></returns>
         protected override Window CreateShell()
         {
+ 
             return Container.Resolve<MainWindow>();
         }
 
@@ -59,6 +66,18 @@ namespace PDF_Office
             containerRegistry.RegisterForNavigation<HomeCloudContent>("Cloud");
             containerRegistry.RegisterForNavigation<HomeToolsContent>("Tools");
             containerRegistry.RegisterForNavigation<HomeGuidContent>("Guid");
+            containerRegistry.RegisterForNavigation<BOTAContent>();
+        }
+
+        protected override void ConfigureRegionAdapterMappings(RegionAdapterMappings regionAdapterMappings)
+        {
+            var region = new SingleActiveRegion() { Name = RegionNames.MainRegion };
+
+            region.Behaviors.Add(DragablzWindowBehavior.BehaviorKey, new DragablzWindowBehavior());
+
+            Container.Resolve<IRegionManager>().Regions.Add(region);
+
+            base.ConfigureRegionAdapterMappings(regionAdapterMappings);
         }
 
         private static bool LicenseVerify()

+ 38 - 0
PDF Office/CustomControl/InterTabClient.cs

@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using Dragablz;
+using PDF_Office.Views;
+using Prism.Ioc;
+using Prism.Regions;
+
+namespace PDF_Office.CustomControl
+{
+    public class InterTabClient : IInterTabClient
+    {
+        private IContainerProvider containerProvider;
+
+        public InterTabClient(IContainerProvider container)
+        {
+            containerProvider = container;
+        }
+
+        public INewTabHost<Window> GetNewHost(IInterTabClient interTabClient, object partition, TabablzControl source)
+        {
+            var view = containerProvider.Resolve<MainWindow>();
+            var regionManager = containerProvider.Resolve<IRegionManager>();
+            RegionManager.SetRegionManager(view, regionManager);
+            RegionManager.UpdateRegions();
+
+            return new NewTabHost<Window>(view, view.TabablzControl);
+        }
+
+        public TabEmptiedResponse TabEmptiedHandler(TabablzControl tabControl, Window window)
+        {
+            return TabEmptiedResponse.CloseWindowOrLayoutBranch;
+        }
+    }
+}

+ 0 - 41
PDF Office/CustomControl/TabItemEx.cs

@@ -1,41 +0,0 @@
-using Prism.Mvvm;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Linq;
-using System.Runtime.CompilerServices;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-
-namespace PDF_Office.CustomControl
-{
-    public class TabItemEx : BindableBase
-    {
-        private string fileName;
-
-        public string FileName
-        {
-            get { return fileName; }
-            set { SetProperty(ref fileName, value); }
-        }
-
-        private string contentName;
-
-        public string ContentName
-        {
-            get { return contentName; }
-            set { SetProperty(ref contentName, value); }
-        }
-
-        private bool isSelected;
-
-        public bool IsSelected
-        {
-            get { return isSelected; }
-            set { SetProperty(ref isSelected, value); }
-        }
-
-    }
-}

+ 224 - 0
PDF Office/CustomControl/TabablzRegionBehavior.cs

@@ -0,0 +1,224 @@
+using Dragablz;
+using PDF_Office.EventAggregators;
+using PDF_Office.Views;
+using Prism.Events;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Collections.Specialized;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Input;
+
+namespace PDF_Office.CustomControl
+{
+    public class DragablzWindowBehavior : RegionBehavior
+    {
+        public const string BehaviorKey = "DragablzWindowBehavior";
+
+        private TabablzControl activeTabcontrol;
+        private readonly ObservableCollection<TabablzControl> tabcontrols;
+
+        public DragablzWindowBehavior()
+        {
+            this.tabcontrols = new ObservableCollection<TabablzControl>();
+        }
+
+        protected override void OnAttach()
+        {
+            this.Region.Views.CollectionChanged += Views_CollectionChanged;
+            this.Region.ActiveViews.CollectionChanged += ActiveViews_CollectionChanged;
+            var eventAggregator = Prism.Ioc.ContainerLocator.Container.Resolve(typeof(IEventAggregator)) as IEventAggregator;
+            eventAggregator.GetEvent<DragablzWindowEvent>().Subscribe(OnDragablzWindowEvent);
+        }
+
+        public void OnDragablzWindowEvent(DragablzWindowEventArgs args)
+        {
+            switch (args.Type)
+            {
+                case DragablzWindowEventType.Opened:
+                    OnWindowOpened(args.TabControl);
+                    break;
+
+                case DragablzWindowEventType.Closed:
+                    OnWindowClosed(args.TabControl);
+                    break;
+
+                case DragablzWindowEventType.Activated:
+                    OnWindowActivated(args.TabControl);
+                    break;
+            }
+        }
+
+        private void OnWindowActivated(TabablzControl tabControl)
+        {
+            if (this.activeTabcontrol != tabControl)
+            {
+                SetActiveView(tabControl);
+            }
+        }
+
+        private void OnWindowClosed(TabablzControl tabControl)
+        {
+            ClearRelatedTabs(tabControl);
+            this.tabcontrols.Remove(tabControl);
+            tabControl.SelectionChanged -= TabControl_SelectionChanged;
+
+            if (this.activeTabcontrol == tabControl)
+            {
+                this.activeTabcontrol = this.tabcontrols.FirstOrDefault();
+            }
+        }
+
+        private void ClearRelatedTabs(TabablzControl tabControl)
+        {
+            var items = tabControl.Items.OfType<MainContent>().ToList();
+
+            items.ForEach(item =>
+            {
+                try
+                {
+                    this.Region.Remove(item.Content);
+                }
+                catch (ArgumentException) { }
+            });
+        }
+
+        private void OnWindowOpened(TabablzControl tabControl)
+        {
+            this.activeTabcontrol = tabControl;
+            this.tabcontrols.Add(tabControl);
+            tabControl.ClosingItemCallback = ClosingItemCallback;
+            tabControl.SelectionChanged += TabControl_SelectionChanged;
+        }
+
+        private void TabControl_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
+        {
+            if (e.AddedItems.Count > 0)
+            {
+                var item = e.AddedItems[0] as MainContent;
+                if (item != null)
+                {
+                    var regionItem = item.Content;
+
+                    if (this.Region.Views.Contains(regionItem))
+                    {
+                        this.Region.Activate(regionItem);
+                    }
+                }
+            }
+        }
+
+
+        private void ClosingItemCallback(ItemActionCallbackArgs<TabablzControl> args)
+        {
+            //remove from region
+                this.Region.Remove(((MainContent)args.DragablzItem.Content));
+        }
+
+        private void ActiveViews_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
+        {
+            switch (e.Action)
+            {
+                case NotifyCollectionChangedAction.Add:
+                    ActivateView(e.NewItems[0]);
+
+                    break;
+            }
+        }
+
+        private void Views_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
+        {
+            switch (e.Action)
+            {
+                case NotifyCollectionChangedAction.Add:
+                    AddView(e.NewItems[0]);
+                    break;
+
+                case NotifyCollectionChangedAction.Remove:
+                    RemoveView(e.OldItems[0]);
+                    break;
+            }
+        }
+
+        public void ActivateView(object view)
+        {
+            var proxy = GetView(view);
+            var tabcontrol = GetTabcontrol(view);
+
+            if (tabcontrol.SelectedItem != proxy || tabcontrol != this.activeTabcontrol)
+            {
+                tabcontrol.SelectedItem = proxy;
+                tabcontrol.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
+            }
+        }
+
+        private void SetActiveView(TabablzControl window)
+        {
+            if (this.activeTabcontrol != window)
+            {
+                this.activeTabcontrol = window;
+                this.activeTabcontrol.BringIntoView();
+                this.activeTabcontrol.Focus();
+
+                var view = this.activeTabcontrol.SelectedItem as MainContent;
+                if (view != null && this.Region.Views.Contains(view.Content))
+                {
+                    this.Region.Activate(view.Content);
+                }
+            }
+        }
+
+        private void RemoveView(object view)
+        {
+            var tabcontrol = GetTabcontrol(view);
+            var proxy = GetView(view);
+            tabcontrol.Items.Remove(proxy);
+            if(tabcontrol.Items.Count<=0)
+            {
+                (Window.GetWindow(tabcontrol) as MainWindow).Close();
+            }
+        }
+
+        private void AddView(object view)
+        {
+            activeTabcontrol = (App.Current.MainWindow as MainWindow).TabablzControl;
+            var item = view as MainContent;
+            if (item != null)
+            {
+                this.activeTabcontrol.Items.Add(item);
+                this.activeTabcontrol.SelectedItem = item;
+            }
+        }
+
+        private TabablzControl GetTabcontrol(object view)
+        {
+            var proxy = GetView(view);
+
+            foreach (var window in this.tabcontrols)
+            {
+                if (ContainsView(window, proxy))
+                {
+                    return window;
+                }
+            }
+
+            return null;
+        }
+
+        private bool ContainsView(TabablzControl window, MainContent proxy)
+        {
+            if (proxy == null || window == null) return false;
+
+            return window.Items.OfType<MainContent>().Any(tc => tc == proxy);
+        }
+
+        private MainContent GetView(object view)
+        {
+            return view as MainContent;
+        }
+    }
+}

+ 28 - 0
PDF Office/EventAggregators/DragablzWindowEvent.cs

@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Dragablz;
+using Prism.Events;
+
+namespace PDF_Office.EventAggregators
+{
+    public class DragablzWindowEvent : PubSubEvent<DragablzWindowEventArgs>
+    {
+
+    }
+
+    public class DragablzWindowEventArgs
+    {
+        public DragablzWindowEventType Type { get; set; }
+        public TabablzControl TabControl { get; set; }
+    }
+
+    public enum DragablzWindowEventType
+    {
+        Opened,
+        Closed,
+        Activated
+    }
+}

+ 19 - 3
PDF Office/PDF Office.csproj

@@ -102,13 +102,23 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </ApplicationDefinition>
+    <Compile Include="CustomControl\InterTabClient.cs" />
     <Compile Include="CustomControl\RegionNames.cs" />
-    <Compile Include="CustomControl\TabItemEx.cs" />
+    <Compile Include="CustomControl\TabablzRegionBehavior.cs" />
+    <Compile Include="EventAggregators\DragablzWindowEvent.cs" />
     <Compile Include="EventAggregators\OpenFileEvent.cs" />
+    <Compile Include="ViewModels\BOTA\BOTAContentViewModel.cs" />
+    <Compile Include="ViewModels\BottomToolContentViewModel.cs" />
     <Compile Include="ViewModels\HomePanel\HomeCloudContentViewModel.cs" />
     <Compile Include="ViewModels\HomePanel\HomeGuidContentViewModel.cs" />
     <Compile Include="ViewModels\HomePanel\HomeToolsContentViewModel.cs" />
     <Compile Include="ViewModels\MainContentViewModel.cs" />
+    <Compile Include="Views\BOTA\BOTAContent.xaml.cs">
+      <DependentUpon>BOTAContent.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\BottomToolContent.xaml.cs">
+      <DependentUpon>BottomToolContent.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Views\HomePanel\HomeCloudContent.xaml.cs">
       <DependentUpon>HomeCloudContent.xaml</DependentUpon>
     </Compile>
@@ -124,6 +134,14 @@
     <Compile Include="Views\ViewContent.xaml.cs">
       <DependentUpon>ViewContent.xaml</DependentUpon>
     </Compile>
+    <Page Include="Views\BOTA\BOTAContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Views\BottomToolContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Views\HomeContent.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
@@ -199,8 +217,6 @@
     <Folder Include="Model\" />
     <Folder Include="Resources\" />
     <Folder Include="Tools\" />
-    <Folder Include="ViewModels\BOTA\" />
-    <Folder Include="Views\BOTA\" />
   </ItemGroup>
   <ItemGroup>
     <Content Include="ComOCRKit.Desk.dll">

+ 18 - 0
PDF Office/ViewModels/BOTA/BOTAContentViewModel.cs

@@ -0,0 +1,18 @@
+using Prism.Mvvm;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.ViewModels.BOTA
+{
+    public class BOTAContentViewModel:BindableBase
+    {
+
+        public BOTAContentViewModel()
+        {
+
+        }
+    }
+}

+ 21 - 0
PDF Office/ViewModels/BottomToolContentViewModel.cs

@@ -0,0 +1,21 @@
+using Prism.Mvvm;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ComPDFKitViewer.PdfViewer;
+
+namespace PDF_Office.ViewModels
+{
+    public class BottomToolContentViewModel:BindableBase
+    {
+        private CPDFViewer PDFViewer { get; set; }
+
+        public BottomToolContentViewModel()
+        {
+            PDFViewer = App.mainWindowViewModel.CurrentPDFViewer;
+        }
+
+    }
+}

+ 4 - 5
PDF Office/ViewModels/HomeContentViewModel.cs

@@ -23,7 +23,7 @@ namespace PDF_Office.ViewModels
 
         private string regionName;
 
-        public string RegionName
+        public string ToolRegionName
         {
             get { return regionName; }
             set { SetProperty(ref regionName, value); }
@@ -44,7 +44,7 @@ namespace PDF_Office.ViewModels
             toolregion = regionManager;
             eventer = eventAggregator;
 
-            RegionName = Guid.NewGuid().ToString();
+            ToolRegionName = Guid.NewGuid().ToString();
             OpenFileCommand = new DelegateCommand(OpenFile);
             ShowToolCommand = new DelegateCommand<string>(ShowToolContent);
         }
@@ -55,7 +55,7 @@ namespace PDF_Office.ViewModels
         /// <param name="view"></param>
         public void ShowToolContent(string view)
         {
-            toolregion.RequestNavigate(RegionName, view);
+            toolregion.RequestNavigate(ToolRegionName, view);
         }
 
         /// <summary>
@@ -85,6 +85,7 @@ namespace PDF_Office.ViewModels
                     var fileList = openFileDialog.FileNames.ToList().Where(x => !App.OpenedFileList.Exists(y => y == x)).ToList();
                     if (fileList.Count <= 0)
                         return;
+
                     mainContentViewModel.OpenFile(fileList[0]);
                     for (int i = 1; i < fileList.Count(); i++)
                     {
@@ -93,7 +94,6 @@ namespace PDF_Office.ViewModels
                             App.mainWindowViewModel.AddTabItem(fileList[i]);
                         }
                     }
-
                 }
             }
         }
@@ -115,7 +115,6 @@ namespace PDF_Office.ViewModels
         public bool IsNavigationTarget(NavigationContext navigationContext)
         {
             return true;
-
         }
 
         public void OnNavigatedFrom(NavigationContext navigationContext)

+ 11 - 27
PDF Office/ViewModels/MainContentViewModel.cs

@@ -15,17 +15,6 @@ using System.Windows;
 
 namespace PDF_Office.ViewModels
 {
-    public enum LoadType
-    {
-        /// <summary>
-        /// 打开文档
-        /// </summary>
-        Open,
-        /// <summary>
-        /// 创建文档
-        /// </summary>
-        Create
-    }
     public class MainContentViewModel : BindableBase, INavigationAware
     {
         private string fileName = "Home";
@@ -63,10 +52,12 @@ namespace PDF_Office.ViewModels
 
         public DelegateCommand<object> CloseTab { get; set; }
 
+        public DelegateCommand<object> Loaded { get; set; }
+
 
         private string regionName;
 
-        public string RegionName
+        public string MainContentRegionName
         {
             get { return regionName; }
             set { SetProperty(ref regionName, value); }
@@ -86,7 +77,7 @@ namespace PDF_Office.ViewModels
 
             CloseTab = new DelegateCommand<object>(CloseTabItem);
 
-            RegionName = Guid.NewGuid().ToString();
+            MainContentRegionName = Guid.NewGuid().ToString();
 
             System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
             {
@@ -96,11 +87,11 @@ namespace PDF_Office.ViewModels
                         "MainViewModel", this
                     }
                 };
-                toolregion.RequestNavigate(RegionName, "HomeContent", parameters);
+                if (toolregion.Regions.ContainsRegionWithName(MainContentRegionName))
+                    toolregion.RequestNavigate(MainContentRegionName, "HomeContent", parameters);
             }));
         }
 
-
         private void CloseTabItem(object item)
         {
             App.mainWindowViewModel?.CloseTabItem(item);
@@ -112,11 +103,12 @@ namespace PDF_Office.ViewModels
         {
             FilePath = filePath;
             NavigationParameters parameters = new NavigationParameters { { "MainViewModel", this } };
+
             System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
             {
-                toolregion.RequestNavigate(RegionName, "ViewContent", parameters);
+                if (toolregion.Regions.ContainsRegionWithName(MainContentRegionName))
+                    toolregion.RequestNavigate(MainContentRegionName, "ViewContent", parameters);
             }));
-     
         }
 
         public void OnNavigatedTo(NavigationContext navigationContext)
@@ -124,7 +116,7 @@ namespace PDF_Office.ViewModels
             if (navigationContext.Parameters.Count <= 0)
                 return;
             var filepath = navigationContext.Parameters["filePath"];
-            if(filepath!=null)
+            if (filepath != null)
             {
                 OpenFile(filepath.ToString());
             }
@@ -132,19 +124,11 @@ namespace PDF_Office.ViewModels
 
         public bool IsNavigationTarget(NavigationContext navigationContext)
         {
-            if (navigationContext.Parameters.Count <= 0)
-                return true;
-            var isAddTab = navigationContext.Parameters["AddTab"];
-            if (isAddTab!=null&&(bool)isAddTab)
-            {
-                return false;
-            }
-            return true;
+            return false;
         }
 
         public void OnNavigatedFrom(NavigationContext navigationContext)
         {
-
         }
     }
 }

+ 45 - 10
PDF Office/ViewModels/MainWindowViewModel.cs

@@ -13,6 +13,10 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows.Controls;
+using ComPDFKitViewer.PdfViewer;
+using Dragablz;
+using System.Windows;
+using Prism.Ioc;
 
 namespace PDF_Office.ViewModels
 {
@@ -28,7 +32,21 @@ namespace PDF_Office.ViewModels
         public MainContent SelectedItem
         {
             get { return selectedItem; }
-            set { SetProperty(ref selectedItem, value); }
+            set {
+                SetProperty(ref selectedItem, value);
+                //TODO:更新CurrentPDFViewer
+            }
+        }
+
+        private CPDFViewer pdfViewer;
+
+        /// <summary>
+        /// 当前页签的PdfViewer对象
+        /// </summary>
+        public CPDFViewer CurrentPDFViewer
+        {
+            get { return pdfViewer; }
+            set { pdfViewer = value; }
         }
 
 
@@ -39,21 +57,33 @@ namespace PDF_Office.ViewModels
 
         public IEventAggregator eventer;
 
-        public MainWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator)
+        private IContainerProvider containerProvider;
+
+        public IInterTabClient InterTabClient { get; }
+
+        public MainWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, IContainerProvider container)
         {
             App.mainWindowViewModel = this;
             region = regionManager;
+
             eventer = eventAggregator;
 
-            AddTab = new DelegateCommand(AddTabItem);
+            containerProvider = container;
 
-            System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() => { region.RequestNavigate(RegionNames.MainRegion, "MainContent"); }));
-            
-        }
+            InterTabClient = new InterTabClient(container);
 
-        public MainWindowViewModel()
-        {
+            AddTab = new DelegateCommand(AddTabItem);
 
+            //第一次打开时需要自动加载Home页
+            if (App.IsFirstOpen)
+            {
+                System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
+                {
+                    region.RequestNavigate(RegionNames.MainRegion, "MainContent");
+                }
+                ));
+                App.IsFirstOpen = false;
+            }
         }
 
         /// <summary>
@@ -65,6 +95,7 @@ namespace PDF_Office.ViewModels
             {
                 { "AddTab",true}
             };
+
             region.RequestNavigate(RegionNames.MainRegion, "MainContent", parameters);
         }
 
@@ -98,8 +129,12 @@ namespace PDF_Office.ViewModels
         public void SelectItem(string filepath)
         {
             var item = region.Regions[RegionNames.MainRegion].Views.Where(t => ((t as MainContent).DataContext as MainContentViewModel).FilePath == filepath).FirstOrDefault() as MainContent;
-            SelectedItem = item;
-
+            region.Regions[RegionNames.MainRegion].Activate(item);
+            var behavior = region.Regions[RegionNames.MainRegion].Behaviors[DragablzWindowBehavior.BehaviorKey] as DragablzWindowBehavior;
+            if(behavior!=null)
+            {
+                behavior.ActivateView(item);
+            }
         }
     }
 }

+ 12 - 5
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -44,10 +44,13 @@ namespace PDF_Office.ViewModels
             ViwerRegionName = Guid.NewGuid().ToString();
             BOTARegionName = Guid.NewGuid().ToString();
             PropertyRegionName = Guid.NewGuid().ToString();
-            ////在构造函数中使用Region需要借助Dispatcher 确保UI已经加载完成
-            //System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() => { loadFile(); }));
-
 
+            //在构造函数中使用Region需要借助Dispatcher 确保UI已经加载完成,加载BOTA区域
+            System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
+                {
+                    region.RequestNavigate(BOTARegionName, "BOTAContent");
+                }
+            ));
         }
 
 
@@ -62,6 +65,10 @@ namespace PDF_Office.ViewModels
             PDFViewer.MouseWheelZoomHandler += PdfViewer_MouseWheelZoomHandler;
             PDFViewer.InitDocument(filepath);
             PDFViewer.Load();
+            if(App.mainWindowViewModel!=null)
+            {
+                App.mainWindowViewModel.CurrentPDFViewer = PDFViewer;
+            }
             App.OpenedFileList.Add(filepath);
             region.AddToRegion(ViwerRegionName, PDFViewer);
         }
@@ -108,7 +115,7 @@ namespace PDF_Office.ViewModels
                 return;
 
             var mainVM = navigationContext.Parameters["MainViewModel"] as MainContentViewModel;
-            if(mainVM!=null)
+            if (mainVM != null)
             {
                 mainViewModel = mainVM;
             }
@@ -123,7 +130,7 @@ namespace PDF_Office.ViewModels
 
         public void OnNavigatedFrom(NavigationContext navigationContext)
         {
-            
+
         }
     }
 }

+ 20 - 0
PDF Office/Views/BOTA/BOTAContent.xaml

@@ -0,0 +1,20 @@
+<UserControl
+    x:Class="PDF_Office.Views.BOTA.BOTAContent"
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+    xmlns:local="clr-namespace:PDF_Office.Views.BOTA"
+    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+    xmlns:prism="http://prismlibrary.com/"
+    d:DesignHeight="450"
+    d:DesignWidth="800"
+    prism:ViewModelLocator.AutoWireViewModel="True"
+    mc:Ignorable="d">
+    <TabControl Background="Transparent" TabStripPlacement="Left">
+        <TabItem Width="48" Height="48" />
+        <TabItem Width="48" Height="48" />
+        <TabItem Width="48" Height="48" />
+        <TabItem Width="48" Height="48" />
+        <TabItem Width="48" Height="48" />
+    </TabControl>
+</UserControl>

+ 28 - 0
PDF Office/Views/BOTA/BOTAContent.xaml.cs

@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace PDF_Office.Views.BOTA
+{
+    /// <summary>
+    /// BOTAContent.xaml 的交互逻辑
+    /// </summary>
+    public partial class BOTAContent : UserControl
+    {
+        public BOTAContent()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 87 - 0
PDF Office/Views/BottomToolContent.xaml

@@ -0,0 +1,87 @@
+<UserControl
+    x:Class="PDF_Office.Views.BottomToolContent"
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+    xmlns:local="clr-namespace:PDF_Office.Views"
+    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+    xmlns:prism="http://prismlibrary.com/"
+    d:DesignHeight="450"
+    d:DesignWidth="1280"
+    prism:ViewModelLocator.AutoWireViewModel="True"
+    mc:Ignorable="d">
+    <Grid Height="32">
+        <Grid.ColumnDefinitions>
+            <ColumnDefinition Width="*"/>
+            <ColumnDefinition Width="auto" MinWidth="{Binding ElementName=StkPnlCenter,Path=ActualWidth}"/>
+            <ColumnDefinition MinWidth="{Binding ElementName=StkPnlRight, Path=ActualWidth}"/>
+        </Grid.ColumnDefinitions>
+        <StackPanel
+            Name="StkPnlCenter"
+            Grid.Column="1"
+            HorizontalAlignment="Center"
+            Orientation="Horizontal">
+            <Button
+                Width="24"
+                Height="24"
+                Margin="4" />
+            <Button
+                Width="24"
+                Height="24"
+                Margin="4" />
+            <TextBox Width="48" />
+            <TextBlock VerticalAlignment="Center" Text="/200" />
+            <Button
+                Width="24"
+                Height="24"
+                Margin="4" />
+            <Button
+                Width="24"
+                Height="24"
+                Margin="4" />
+        </StackPanel>
+        <StackPanel
+            x:Name="StkPnlRight"
+            Grid.Column="2"
+            HorizontalAlignment="Right"
+            Orientation="Horizontal">
+            <ToggleButton
+                Width="24"
+                Height="24"
+                Margin="4" />
+            <Separator
+                Width="1"
+                Height="10"
+                Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" />
+            <Button
+                Width="24"
+                Height="24"
+                Margin="4" />
+            <Button
+                Width="24"
+                Height="24"
+                Margin="4" />
+            <Button
+                Width="24"
+                Height="24"
+                Margin="4" />
+            <Separator
+                Width="1"
+                Height="10"
+                Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" />
+            <Button
+                Width="24"
+                Height="24"
+                Margin="4" />
+            <ToggleButton
+                Width="24"
+                Height="24"
+                Margin="4" />
+            <Control Width="80" />
+            <Button
+                Width="24"
+                Height="24"
+                Margin="4" />
+        </StackPanel>
+    </Grid>
+</UserControl>

+ 28 - 0
PDF Office/Views/BottomToolContent.xaml.cs

@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace PDF_Office.Views
+{
+    /// <summary>
+    /// BottomToolContent.xaml 的交互逻辑
+    /// </summary>
+    public partial class BottomToolContent : UserControl
+    {
+        public BottomToolContent()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 1 - 1
PDF Office/Views/HomeContent.xaml

@@ -54,6 +54,6 @@
                 Content="Cloud" />
         </StackPanel>
         <!--  右侧内容区域  -->
-        <ContentControl Grid.Column="1" prism:RegionManager.RegionName="{Binding RegionName}" />
+        <ContentControl Grid.Column="1" prism:RegionManager.RegionName="{Binding ToolRegionName}" />
     </Grid>
 </UserControl>

+ 7 - 1
PDF Office/Views/MainContent.xaml

@@ -3,6 +3,7 @@
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+    xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
     xmlns:local="clr-namespace:PDF_Office.Views"
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
     xmlns:prism="http://prismlibrary.com/"
@@ -10,5 +11,10 @@
     d:DesignWidth="800"
     prism:ViewModelLocator.AutoWireViewModel="True"
     mc:Ignorable="d">
-    <ContentControl prism:RegionManager.RegionName="{Binding RegionName}" />
+    <!--<i:Interaction.Triggers>
+        <i:EventTrigger EventName="Loaded">
+            <prism:InvokeCommandAction Command="{Binding Loaded}" CommandParameter="{Binding}" />
+        </i:EventTrigger>
+    </i:Interaction.Triggers>-->
+    <ContentControl Name="ContentMain" prism:RegionManager.RegionName="{Binding MainContentRegionName}" />
 </UserControl>

+ 4 - 1
PDF Office/Views/MainContent.xaml.cs

@@ -1,4 +1,7 @@
-using System;
+using PDF_Office.ViewModels;
+using Prism.Ioc;
+using Prism.Regions;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;

+ 100 - 76
PDF Office/Views/MainWindow.xaml

@@ -12,24 +12,19 @@
     xmlns:viewmodels="clr-namespace:PDF_Office.ViewModels"
     Width="1280"
     Height="800"
-    MinWidth="1280"
+    MinWidth="800"
     MinHeight="800"
     prism:ViewModelLocator.AutoWireViewModel="True"
     Activated="Window_Activated"
+    Closed="Window_Closed"
+    Style="{DynamicResource WindowStyle}"
+    UseLayoutRounding="True"
     WindowStartupLocation="CenterScreen"
     mc:Ignorable="d">
-    <WindowChrome.WindowChrome>
-        <WindowChrome
-            CaptionHeight="30"
-            CornerRadius="0"
-            GlassFrameThickness="-1"
-            NonClientFrameEdges="None"
-            ResizeBorderThickness="3"
-            UseAeroCaptionButtons="False" />
-    </WindowChrome.WindowChrome>
     <Window.Resources>
         <ResourceDictionary>
             <Style x:Key="DragablzItemStyle" TargetType="{x:Type dragablz:DragablzItem}">
+                <Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True" />
                 <Setter Property="Template">
                     <Setter.Value>
                         <ControlTemplate TargetType="dragablz:DragablzItem">
@@ -45,7 +40,8 @@
                                     Margin="4,0,0,2"
                                     BorderBrush="#A0A2AE"
                                     BorderThickness="1,1,1,0"
-                                    CornerRadius="5,5,0,0">
+                                    CornerRadius="5,5,0,0"
+                                    WindowChrome.IsHitTestVisibleInChrome="True">
                                     <Grid Background="Transparent">
                                         <Grid.ColumnDefinitions>
                                             <ColumnDefinition Width="auto" />
@@ -125,72 +121,100 @@
                     </Setter.Value>
                 </Setter>
             </Style>
+
+            <Style x:Key="WindowStyle" TargetType="{x:Type Window}">
+                <Setter Property="WindowChrome.WindowChrome">
+                    <Setter.Value>
+                        <WindowChrome
+                            CaptionHeight="32"
+                            CornerRadius="10"
+                            GlassFrameThickness="-1"
+                            ResizeBorderThickness="5"
+                            UseAeroCaptionButtons="False" />
+                    </Setter.Value>
+                </Setter>
+                <Setter Property="Template">
+                    <Setter.Value>
+                        <ControlTemplate TargetType="{x:Type Window}">
+                            <Border
+                                Background="{TemplateBinding Background}"
+                                BorderBrush="{TemplateBinding BorderBrush}"
+                                BorderThickness="{TemplateBinding BorderThickness}">
+                                <AdornerDecorator>
+                                    <ContentPresenter x:Name="win_content" />
+                                </AdornerDecorator>
+                            </Border>
+                            <ControlTemplate.Triggers>
+                                <Trigger Property="WindowState" Value="Maximized">
+                                    <!--  调整边框  -->
+                                    <Setter TargetName="win_content" Property="Margin" Value="5,5,5,5" />
+                                </Trigger>
+                            </ControlTemplate.Triggers>
+                        </ControlTemplate>
+                    </Setter.Value>
+                </Setter>
+            </Style>
         </ResourceDictionary>
     </Window.Resources>
-    <Grid>
-        <Grid.RowDefinitions>
-            <RowDefinition Height="40" />
-            <RowDefinition Height="*" />
-        </Grid.RowDefinitions>
-        <dragablz:TabablzControl
-            Name="PDFViewerTab"
-            Grid.RowSpan="2"
-            prism:RegionManager.RegionName="{x:Static cus:RegionNames.MainRegion}"
-            BorderThickness="0"
-            ItemContainerStyle="{StaticResource DragablzItemStyle}"
-            SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
-            WindowChrome.IsHitTestVisibleInChrome="True">
-            <dragablz:TabablzControl.InterTabController>
-                <dragablz:InterTabController />
-            </dragablz:TabablzControl.InterTabController>
-            <dragablz:TabablzControl.HeaderSuffixContent>
+    <Border>
+        <Grid>
+            <Grid.RowDefinitions>
+                <RowDefinition Height="40" />
+                <RowDefinition Height="*" />
+            </Grid.RowDefinitions>
+            <dragablz:TabablzControl
+                Name="TabablzControl"
+                Grid.RowSpan="2"
+                BorderThickness="0"
+                ItemContainerStyle="{StaticResource DragablzItemStyle}"
+                SelectedItem="{Binding SelectedItem, Mode=TwoWay}">
+                <dragablz:TabablzControl.InterTabController>
+                    <dragablz:InterTabController InterTabClient="{Binding InterTabClient}" />
+                </dragablz:TabablzControl.InterTabController>
+                <dragablz:TabablzControl.HeaderSuffixContent>
+                    <Button
+                        x:Name="BtnAdd"
+                        Width="16"
+                        Height="16"
+                        Margin="9,7,200,5"
+                        HorizontalAlignment="Left"
+                        Background="Transparent"
+                        BorderThickness="0"
+                        Command="{Binding AddTab}"
+                        Content="+"
+                        WindowChrome.IsHitTestVisibleInChrome="True" />
+                </dragablz:TabablzControl.HeaderSuffixContent>
+                <dragablz:TabablzControl.HeaderPrefixContent>
+                    <Grid
+                        Width="16"
+                        Height="38"
+                        Margin="0,2,0,0"
+                        Background="Transparent" />
+                </dragablz:TabablzControl.HeaderPrefixContent>
+            </dragablz:TabablzControl>
+            <!--  标题栏右侧栏,关闭按钮,会员,试用等  -->
+            <StackPanel
+                HorizontalAlignment="Right"
+                Orientation="Horizontal"
+                WindowChrome.IsHitTestVisibleInChrome="True">
                 <Button
-                    x:Name="BtnAdd"
-                    Width="16"
-                    Height="16"
-                    Margin="9,7,200,5"
-                    HorizontalAlignment="Left"
-                    Background="Transparent"
-                    BorderThickness="0"
-                    Command="{Binding AddTab}"
-                    Content="+" />
-            </dragablz:TabablzControl.HeaderSuffixContent>
-            <dragablz:TabablzControl.HeaderPrefixContent>
-                <Grid
-                    Width="16"
-                    Height="38"
-                    Margin="0,2,0,0"
-                    Background="Transparent" />
-            </dragablz:TabablzControl.HeaderPrefixContent>
-            <!--<TabItem Name="HomeTabControlItem">
-                <TabItem.Content>
-                    <ContentControl prism:RegionManager.RegionName="ViwerRegion" />
-                </TabItem.Content>
-            </TabItem>-->
-        </dragablz:TabablzControl>
-
-        <!--  标题栏右侧栏,关闭按钮,会员,试用等  -->
-        <StackPanel
-            HorizontalAlignment="Right"
-            Orientation="Horizontal"
-            WindowChrome.IsHitTestVisibleInChrome="True">
-            <Button
-                Name="BtnMiniSize"
-                Width="40"
-                Height="40"
-                Click="BtnMiniSize_Click"
-                Content="--" />
-            <Button
-                Name="BtnReStore"
-                Width="40"
-                Height="40"
-                Click="BtnReStore_Click" />
-            <Button
-                Name="BtnClose"
-                Width="40"
-                Height="40"
-                Click="BtnClose_Click"
-                Content="X" />
-        </StackPanel>
-    </Grid>
+                    Name="BtnMiniSize"
+                    Width="40"
+                    Height="40"
+                    Click="BtnMiniSize_Click"
+                    Content="--" />
+                <Button
+                    Name="BtnReStore"
+                    Width="40"
+                    Height="40"
+                    Click="BtnReStore_Click" />
+                <Button
+                    Name="BtnClose"
+                    Width="40"
+                    Height="40"
+                    Click="BtnClose_Click"
+                    Content="X" />
+            </StackPanel>
+        </Grid>
+    </Border>
 </Window>

+ 25 - 1
PDF Office/Views/MainWindow.xaml.cs

@@ -14,6 +14,10 @@ using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Navigation;
 using System.Windows.Shapes;
+using Prism.Events;
+using PDF_Office.EventAggregators;
+using PDF_Office.CustomControl;
+using Prism.Ioc;
 
 namespace PDF_Office.Views
 {
@@ -22,12 +26,26 @@ namespace PDF_Office.Views
     /// </summary>
     public partial class MainWindow : Window
     {
-        public HomeContentViewModel HomeViewModel;
+        public IEventAggregator aggregator;
+
+        public IRegionManager region;
+
         public MainWindow()
         {
             InitializeComponent();
         }
 
+        /// <summary>
+        /// 此类因为Dragablz控件的原因需要特殊处理
+        /// </summary>
+        /// <param name="eventAggregator"></param>
+
+        public MainWindow(IEventAggregator eventAggregator, IContainerProvider container) :this()
+        {
+            aggregator = eventAggregator;
+            eventAggregator?.GetEvent<DragablzWindowEvent>().Publish(new DragablzWindowEventArgs() { TabControl = TabablzControl, Type = DragablzWindowEventType.Opened });
+        }
+
         private void BtnMiniSize_Click(object sender, RoutedEventArgs e)
         {
             System.Windows.SystemCommands.MinimizeWindow(this);
@@ -49,6 +67,12 @@ namespace PDF_Office.Views
         private void Window_Activated(object sender, EventArgs e)
         {
             App.Current.MainWindow = this;
+            aggregator?.GetEvent<DragablzWindowEvent>().Publish(new DragablzWindowEventArgs() { TabControl = TabablzControl, Type = DragablzWindowEventType.Activated });
+        }
+
+        private void Window_Closed(object sender, EventArgs e)
+        {
+            aggregator?.GetEvent<DragablzWindowEvent>().Publish(new DragablzWindowEventArgs() { TabControl = TabablzControl, Type = DragablzWindowEventType.Closed });
         }
     }
 }

+ 74 - 6
PDF Office/Views/ViewContent.xaml

@@ -128,6 +128,47 @@
             <RowDefinition Height="*" />
             <RowDefinition Height="24" />
         </Grid.RowDefinitions>
+        <!--  左边菜单按钮  -->
+        <StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
+            <Button
+                Width="16"
+                Height="16"
+                Margin="8"
+                ToolTip="File" />
+            <Button
+                Width="16"
+                Height="16"
+                Margin="8"
+                ToolTip="Save" />
+            <Button
+                Width="16"
+                Height="16"
+                Margin="8"
+                ToolTip="Undo" />
+            <Button
+                Width="16"
+                Height="16"
+                Margin="8"
+                ToolTip="Redo" />
+        </StackPanel>
+        <!--  右边菜单按钮  -->
+        <StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
+            <Button
+                Width="16"
+                Height="16"
+                Margin="8"
+                ToolTip="Print" />
+            <Button
+                Width="16"
+                Height="16"
+                Margin="8"
+                ToolTip="Share" />
+            <Button
+                Width="16"
+                Height="16"
+                Margin="8"
+                ToolTip="Property" />
+        </StackPanel>
         <TabControl
             x:Name="ToolTabControl"
             Grid.Row="0"
@@ -135,16 +176,35 @@
             VerticalAlignment="Top"
             BorderThickness="0"
             Style="{StaticResource TabControlWithUnderLineStyle}">
-            <TabItem Header="Tool">
-                <Grid Grid.Row="1" Height="20" />
+            <TabItem Height="40" Header="注释">
+                <Grid Grid.Row="1" Height="40" />
+            </TabItem>
+            <TabItem Header="页面" />
+            <TabItem Header="转换" />
+            <TabItem Header="扫描和OCR">
+                <Grid Grid.Row="1" Height="40" />
+            </TabItem>
+            <TabItem Height="40" Header="编辑">
+                <Grid Grid.Row="1" Height="40" />
+            </TabItem>
+            <TabItem Height="40" Header="表单">
+                <Grid Grid.Row="1" Height="40" />
+            </TabItem>
+            <TabItem Height="40" Header="填写与签名">
+                <Grid Grid.Row="1" Height="40" />
+            </TabItem>
+            <TabItem Height="40" Header="工具">
+                <Grid Grid.Row="1" Height="40" />
             </TabItem>
-            <TabItem Header="Page Edit" />
-            <TabItem Header="Form" />
         </TabControl>
         <Grid Name="DocumentView" Grid.Row="2">
             <Grid.ColumnDefinitions>
-                <ColumnDefinition x:Name="BOTACloumn" Width="40" />
-                <ColumnDefinition Width="12" MaxWidth="400" />
+                <ColumnDefinition
+                    x:Name="BOTACloumn"
+                    Width="48"
+                    MinWidth="48"
+                    MaxWidth="400" />
+                <ColumnDefinition Width="12" />
                 <ColumnDefinition
                     Name="ViewerColumn"
                     Width="*"
@@ -167,5 +227,13 @@
             <Button Grid.Column="3" />
             <ContentControl Grid.Column="4" prism:RegionManager.RegionName="{Binding PropertyRegionName}" />
         </Grid>
+        <local:BottomToolContent Grid.Row="3" />
+
+        <ContentControl
+            Grid.Row="2"
+            Grid.RowSpan="2"
+            Visibility="Collapsed">
+            <Grid Background="Red" />
+        </ContentControl>
     </Grid>
 </UserControl>