Преглед изворни кода

主页-多页签UI和升级icon重叠

OYXH\oyxh пре 1 година
родитељ
комит
16d03eaf8d
2 измењених фајлова са 162 додато и 125 уклоњено
  1. 106 106
      PDF Office/Views/MainWindow.xaml
  2. 56 19
      PDF Office/Views/MainWindow.xaml.cs

+ 106 - 106
PDF Office/Views/MainWindow.xaml

@@ -16,7 +16,6 @@
     Height="800"
     MinWidth="640"
     MinHeight="460"
-    Loaded="Window_Loaded"
     d:DataContext="{d:DesignInstance Type=viewmodels:MainWindowViewModel}"
     prism:ViewModelLocator.AutoWireViewModel="True"
     Activated="Window_Activated"
@@ -24,6 +23,7 @@
     BorderThickness="2"
     Closed="Window_Closed"
     Closing="Window_Closing"
+    Loaded="Window_Loaded"
     PreviewMouseLeftButtonDown="Window_PreviewMouseLeftButtonDown"
     SizeChanged="Window_SizeChanged"
     SnapsToDevicePixels="True"
@@ -183,7 +183,7 @@
                                     </MultiDataTrigger.Conditions>
                                     <Setter TargetName="Title" Property="Background" Value="#0D000000" />
                                     <Setter Property="Foreground" Value="{StaticResource color.sys.text.neutral.lv1}" />
-                                    <!--<Setter TargetName="btnPath" Property="Path.Fill" Value="Black"/>-->
+                                    <!--<Setter TargetName="btnPath" Property="Path.Fill" Value="Black" />-->
                                 </MultiDataTrigger>
                             </ControlTemplate.Triggers>
                         </ControlTemplate>
@@ -243,9 +243,8 @@
         <!--  标题栏右侧栏,关闭按钮,会员,试用等  -->
         <DockPanel HorizontalAlignment="Right">
             <Grid
-                DockPanel.Dock="Left"
                 x:Name="Grid_Openhight"
-                IsVisibleChanged="Grid_Openhight_IsVisibleChanged"
+                DockPanel.Dock="Left"
                 Visibility="Collapsed">
 
                 <WrapPanel VerticalAlignment="Center">
@@ -257,12 +256,9 @@
                         VerticalAlignment="Center"
                         Background=" #FFCF52"
                         CornerRadius="4" />
-
-
                     <Border VerticalAlignment="Center">
                         <Path Data="M0 4C0 1.79086 1.79086 0 4 0H132C134.209 0 136 1.79086 136 4V10.323C136 10.7319 136.249 11.0996 136.629 11.2514L141.179 13.0715C142.017 13.4068 142.017 14.5932 141.179 14.9285L136.629 16.7486C136.249 16.9004 136 17.2681 136 17.677V24C136 26.2091 134.209 28 132 28H4C1.79086 28 0 26.2091 0 24V4Z" Fill="#FFCF52" />
                     </Border>
-
                 </WrapPanel>
                 <TextBlock
                     HorizontalAlignment="Center"
@@ -273,127 +269,132 @@
                     Text="{Binding Msgtologin}" />
             </Grid>
             <StackPanel
-            Name="StkPnlRight"
-            HorizontalAlignment="Right"
-            Orientation="Horizontal"
-            WindowChrome.IsHitTestVisibleInChrome="True">
+                Name="StkPnlRight"
+                HorizontalAlignment="Right"
+                Orientation="Horizontal"
+                WindowChrome.IsHitTestVisibleInChrome="True">
 
-                <Border Width="87" Height="24"  Visibility="{Binding UpgradeVis}">
+                <Border
+                    Name="BorderUpgrade"
+                    Width="87"
+                    Height="24"
+                    IsVisibleChanged="Grid_Openhight_IsVisibleChanged"
+                    Visibility="{Binding UpgradeVis}">
                     <Border.InputBindings>
-                        <MouseBinding MouseAction="LeftClick" Command="{Binding  UpgradelinkCommand}" />
+                        <MouseBinding Command="{Binding UpgradelinkCommand}" MouseAction="LeftClick" />
                     </Border.InputBindings>
                     <Image Source="pack://application:,,,/PDF Master;component/Resources/Service/Upgrade.png" />
-                    </Border>
+                </Border>
 
-               
                 <Button
-                x:Name="Btn_Register"
-                Width="40"
-                Height="40"
-                Background="Transparent"
-                Command="{Binding OpenRegisterCommand}"
-                Style="{StaticResource subToolBar}"
-                Visibility="{Binding RegisterVis, Mode=TwoWay}">
+                    x:Name="Btn_Register"
+                    Width="40"
+                    Height="40"
+                    Background="Transparent"
+                    Command="{Binding OpenRegisterCommand}"
+                    Style="{StaticResource subToolBar}"
+                    Visibility="{Binding RegisterVis, Mode=TwoWay}">
                     <Grid>
                         <Border
-                        x:Name="myBorder1"
-                        Width="24"
-                        Height="24"
-                        Background="White"
-                        CornerRadius="12" />
+                            x:Name="myBorder1"
+                            Width="24"
+                            Height="24"
+                            Background="White"
+                            CornerRadius="12" />
                         <Border
-                        Width="24"
-                        Height="24"
-                        Background="{StaticResource color.icon.base.neutral.norm.lv1}"
-                        BorderBrush="{StaticResource color.icon.base.neutral.norm.lv1}">
+                            Width="24"
+                            Height="24"
+                            Background="{StaticResource color.icon.base.neutral.norm.lv1}"
+                            BorderBrush="{StaticResource color.icon.base.neutral.norm.lv1}">
                             <Path Data="M12 13C14.2091 13 16 11.2091 16 9C16 6.79086 14.2091 5 12 5C9.79086 5 8 6.79086 8 9C8 11.2091 9.79086 13 12 13ZM12 31C17.5228 31 22 27.4183 22 23C22 18.5817 17.5228 15 12 15C6.47715 15 2 18.5817 2 23C2 27.4183 6.47715 31 12 31Z" Fill="White" />
                             <Border.OpacityMask>
                                 <VisualBrush Visual="{Binding ElementName=myBorder1}" />
                             </Border.OpacityMask>
                         </Border>
                         <Border
-                        Width="24"
-                        Height="24"
-                        BorderBrush="{StaticResource color.icon.base.neutral.norm.lv1}"
-                        BorderThickness="2"
-                        CornerRadius="100" />
+                            Width="24"
+                            Height="24"
+                            BorderBrush="{StaticResource color.icon.base.neutral.norm.lv1}"
+                            BorderThickness="2"
+                            CornerRadius="100" />
                     </Grid>
-
                 </Button>
 
                 <Button
-                x:Name="Btn_Login"
-                Width="40"
-                Height="40"
-                Background="Transparent"
-                Command="{Binding OpenLoginCommand}"
-                Style="{StaticResource subToolBar}"
-                Visibility="{Binding LoginVis, Mode=TwoWay}">
+                    x:Name="Btn_Login"
+                    Width="40"
+                    Height="40"
+                    Background="Transparent"
+                    Command="{Binding OpenLoginCommand}"
+                    Style="{StaticResource subToolBar}"
+                    Visibility="{Binding LoginVis, Mode=TwoWay}">
                     <Grid>
                         <Border
-                        x:Name="myBorder2"
-                        Width="24"
-                        Height="24"
-                        Background="White"
-                        CornerRadius="12" />
+                            x:Name="myBorder2"
+                            Width="24"
+                            Height="24"
+                            Background="White"
+                            CornerRadius="12" />
                         <Border
-                        Width="24"
-                        Height="24"
-                        Background="{StaticResource color.icon.base.neutral.norm.lv1}"
-                        BorderBrush="{StaticResource color.icon.base.neutral.norm.lv1}">
+                            Width="24"
+                            Height="24"
+                            Background="{StaticResource color.icon.base.neutral.norm.lv1}"
+                            BorderBrush="{StaticResource color.icon.base.neutral.norm.lv1}">
                             <Path Data="M12 13C14.2091 13 16 11.2091 16 9C16 6.79086 14.2091 5 12 5C9.79086 5 8 6.79086 8 9C8 11.2091 9.79086 13 12 13ZM12 31C17.5228 31 22 27.4183 22 23C22 18.5817 17.5228 15 12 15C6.47715 15 2 18.5817 2 23C2 27.4183 6.47715 31 12 31Z" Fill="White" />
                             <Border.OpacityMask>
                                 <VisualBrush Visual="{Binding ElementName=myBorder2}" />
                             </Border.OpacityMask>
                         </Border>
                         <Border
-                        Width="24"
-                        Height="24"
-                        BorderBrush="{StaticResource color.icon.base.neutral.norm.lv1}"
-                        BorderThickness="2"
-                        CornerRadius="100" />
+                            Width="24"
+                            Height="24"
+                            BorderBrush="{StaticResource color.icon.base.neutral.norm.lv1}"
+                            BorderThickness="2"
+                            CornerRadius="100" />
                     </Grid>
                 </Button>
                 <Button
-                x:Name="Btn_User"
-                Width="40"
-                Height="40"
-                Background="Transparent"
-                Command="{Binding OpenUserCommand}"
-                Style="{StaticResource subToolBar}"
-                Visibility="{Binding UserVis, Mode=TwoWay}">
+                    x:Name="Btn_User"
+                    Width="40"
+                    Height="40"
+                    Background="Transparent"
+                    Command="{Binding OpenUserCommand}"
+                    Style="{StaticResource subToolBar}"
+                    Visibility="{Binding UserVis, Mode=TwoWay}">
                     <Grid>
                         <Border
-                        Width="24"
-                        Height="24"
-                        Background="#1770F4"
-                        BorderBrush="#1770F4"
-                        CornerRadius="100">
+                            Width="24"
+                            Height="24"
+                            Background="#1770F4"
+                            BorderBrush="#1770F4"
+                            CornerRadius="100">
                             <TextBlock
-                            HorizontalAlignment="Center"
-                            VerticalAlignment="Center"
-                            FontFamily="SF Pro Text"
-                            FontSize="14"
-                            FontWeight="SemiBold"
-                            Foreground="White"
-                          Text="{Binding Useremailchar,Mode=TwoWay}" />
+                                HorizontalAlignment="Center"
+                                VerticalAlignment="Center"
+                                FontFamily="SF Pro Text"
+                                FontSize="14"
+                                FontWeight="SemiBold"
+                                Foreground="White"
+                                Text="{Binding Useremailchar, Mode=TwoWay}" />
                         </Border>
-
                     </Grid>
                 </Button>
-                <Separator Background="{StaticResource color.sys.layout.divider}" Width="16" Height="1">
+                <Separator
+                    Width="16"
+                    Height="1"
+                    Background="{StaticResource color.sys.layout.divider}">
                     <Separator.LayoutTransform>
                         <RotateTransform Angle="90" />
                     </Separator.LayoutTransform>
                 </Separator>
                 <Button
-                Name="BtnMiniSize"
-                Width="46"
-                Height="40"
-                Background="Transparent"
-                BorderThickness="0"
-                Click="BtnMiniSize_Click"
-                Style="{StaticResource TitleBarBtn}">
+                    Name="BtnMiniSize"
+                    Width="46"
+                    Height="40"
+                    Background="Transparent"
+                    BorderThickness="0"
+                    Click="BtnMiniSize_Click"
+                    Style="{StaticResource TitleBarBtn}">
                     <Polygon Fill="{StaticResource color.btn.sec.text.def}" Points="14 7 14 8 2 8 2 7">
                         <Polygon.RenderTransform>
                             <TransformGroup>
@@ -403,19 +404,19 @@
                     </Polygon>
                 </Button>
                 <Button
-                Name="BtnReStore"
-                Width="46"
-                Height="40"
-                Background="Transparent"
-                BorderThickness="0"
-                Click="BtnReStore_Click"
-                Style="{StaticResource TitleBarBtn}">
+                    Name="BtnReStore"
+                    Width="46"
+                    Height="40"
+                    Background="Transparent"
+                    BorderThickness="0"
+                    Click="BtnReStore_Click"
+                    Style="{StaticResource TitleBarBtn}">
                     <Grid>
                         <Path
-                        x:Name="ico_max"
-                        Data="M14,2 L14,14 L2,14 L2,2 L14,2 Z M13,3 L3,3 L3,13 L13,13 L13,3 Z"
-                        Fill="{StaticResource color.btn.sec.text.def}"
-                        Visibility="Collapsed" />
+                            x:Name="ico_max"
+                            Data="M14,2 L14,14 L2,14 L2,2 L14,2 Z M13,3 L3,3 L3,13 L13,13 L13,3 Z"
+                            Fill="{StaticResource color.btn.sec.text.def}"
+                            Visibility="Collapsed" />
                         <Grid x:Name="ico_mini" Visibility="{Binding ElementName=ico_max, Path=Visibility, Converter={StaticResource UnvisibleConvert}}">
                             <Path Data="M11,5 L11,14 L2,14 L2,5 L11,5 Z M10,6 L3,6 L3,13 L10,13 L10,6 Z" Fill="{StaticResource color.btn.sec.text.def}" />
                             <Polygon Fill="{StaticResource color.btn.sec.text.def}" Points="14 2 14 11 11 11 11 10 13 10 13 3 6 3 6 5 5 5 5 2" />
@@ -423,18 +424,17 @@
                     </Grid>
                 </Button>
                 <Button
-                Name="BtnClose"
-                Width="46"
-                Height="40"
-                Background="Transparent"
-                BorderThickness="0"
-                Click="BtnClose_Click"
-                Style="{StaticResource CloseBtn}">
+                    Name="BtnClose"
+                    Width="46"
+                    Height="40"
+                    Background="Transparent"
+                    BorderThickness="0"
+                    Click="BtnClose_Click"
+                    Style="{StaticResource CloseBtn}">
                     <Polygon Fill="{StaticResource color.btn.sec.text.def}" Points="11.2919922 12 12 11.2919922 6.70800781 6 12 0.708007813 11.2919922 0 6 5.29199219 0.708007812 9.76996262e-15 -2.27456942e-13 0.708007813 5.29199219 6 0 11.2919922 0.708007812 12 6 6.70800781" />
                 </Button>
             </StackPanel>
         </DockPanel>
-       
 
         <!--  OCR Progress Control  -->
         <Grid Grid.RowSpan="2" Visibility="{Binding IsProcessVisible}">
@@ -480,4 +480,4 @@
             </Border>
         </Grid>
     </Grid>
-</Window>
+</Window>

+ 56 - 19
PDF Office/Views/MainWindow.xaml.cs

@@ -26,6 +26,7 @@ using PDF_Master.Properties;
 using System.Windows.Interop;
 using System.Runtime.InteropServices;
 using System.Security.Cryptography;
+using System.Diagnostics;
 
 namespace PDF_Master.Views
 {
@@ -38,6 +39,11 @@ namespace PDF_Master.Views
 
         public IRegionManager region;
 
+        /// <summary>
+        /// 窗口大小是否改变
+        /// </summary>
+        private bool sizeChange = false;
+
         public MainWindow()
         {
             InitializeComponent();
@@ -85,7 +91,6 @@ namespace PDF_Master.Views
                     }
                     if (File.Exists(filePath))
                     {
-
                         //打开传过来的文件路径
                         if (App.OpenedFileList.Contains(filePath))
                         {
@@ -105,18 +110,15 @@ namespace PDF_Master.Views
                 }
                 catch
                 {
-
                 }
                 handled = true;
                 return (IntPtr)(1);
             }
-            if (msg == App.WakeId|| msg == App.WebopenexpiredId)
+            if (msg == App.WakeId || msg == App.WebopenexpiredId)
             {
-              
                 //将现有窗口激活 并前置
                 try
                 {
-                   
                     Activate();
                     //最小化后激活
                     if (this.WindowState == WindowState.Minimized)
@@ -127,14 +129,14 @@ namespace PDF_Master.Views
                     Topmost = true;
                     Topmost = false;
                     ServiceHelper.GetUser();
-                    if(msg==App.WebopenexpiredId)
+                    if (msg == App.WebopenexpiredId)
                     {
-                        if (App.IsLogin == true&&App.UserOpen==false)
+                        if (App.IsLogin == true && App.UserOpen == false)
                         {
                             App.mainWindowViewModel.OpenUser();
                             App.WebOpencase = "";
                         }
-                        else if(App.IsLogin == false&&App.LoginOpen == false)
+                        else if (App.IsLogin == false && App.LoginOpen == false)
                         {
                             App.mainWindowViewModel.OpenLogin();
                             App.WebOpencase = "";
@@ -144,7 +146,6 @@ namespace PDF_Master.Views
                 }
                 catch
                 {
-
                 }
 
                 return (IntPtr)(1);
@@ -157,7 +158,7 @@ namespace PDF_Master.Views
         /// </summary>
         /// <param name="eventAggregator"></param>
 
-        public MainWindow(IEventAggregator eventAggregator, IContainerProvider container) :this()
+        public MainWindow(IEventAggregator eventAggregator, IContainerProvider container) : this()
         {
             aggregator = eventAggregator;
             eventAggregator?.GetEvent<DragablzWindowEvent>().Publish(new DragablzWindowEventArgs() { TabControl = TabablzControl, Type = DragablzWindowEventType.Opened });
@@ -192,8 +193,8 @@ namespace PDF_Master.Views
             aggregator?.GetEvent<DragablzWindowEvent>().Publish(new DragablzWindowEventArgs() { TabControl = TabablzControl, Type = DragablzWindowEventType.Activated });
             //只需要第一次激活时获取一次信息
 
-            if(App.IsFirstOpen)
-            {            
+            if (App.IsFirstOpen)
+            {
                 //判断本地有没有token,没有显示登录,有再判断登录状态
                 if (Settings.Default.AppProperties.LoginToken != "")
                 {
@@ -247,7 +248,7 @@ namespace PDF_Master.Views
             //设为默认浏览器后,外部点击文档打开
             if (App.NeedOpenFilePathList.Count != 0)
             {
-                for(int i=0;i<App.NeedOpenFilePathList.Count;i++)
+                for (int i = 0; i < App.NeedOpenFilePathList.Count; i++)
                 {
                     (this.DataContext as MainWindowViewModel).AddTabItem(App.NeedOpenFilePathList[i]);
                     await Task.Delay(50);
@@ -298,7 +299,6 @@ namespace PDF_Master.Views
 
         private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
         {
-            UpdateTitleMargin();
             if (this.WindowState == WindowState.Maximized)
             {
                 ico_max.Visibility = Visibility.Collapsed;
@@ -307,6 +307,12 @@ namespace PDF_Master.Views
             {
                 ico_max.Visibility = Visibility.Visible;
             }
+
+            UpdateTitleMargin();
+            if (this.ActualWidth != 1280)
+            {
+                sizeChange = true;
+            }
         }
 
         /// <summary>
@@ -315,13 +321,44 @@ namespace PDF_Master.Views
         private void UpdateTitleMargin()
         {
             var width = StkPnlRight.ActualWidth;
-            BtnAdd.Margin = new Thickness(8, 13, width, 7);
+            double width1 = this.ActualWidth;
+            double width2 = TabablzControl.ActualWidth;
+            if (BorderUpgrade.Visibility == Visibility.Collapsed)
+            {
+                BtnAdd.Margin = new Thickness(8, 13, width, 7);
+                Trace.WriteLine("BorderUpgrade.Collapsed " + width1);
+                Trace.WriteLine("BorderUpgrade.Collapsed " + width2);
+                Trace.WriteLine("BorderUpgrade.Collapsed " + width);
+            }
+            else
+            {
+                Trace.WriteLine("BorderUpgrade.Visibility " + width1);
+                Trace.WriteLine("BorderUpgrade.Visibility " + width2);
+                Trace.WriteLine("BorderUpgrade.Visibility " + width);
+                if (this.WindowState == WindowState.Maximized)
+                {
+                    BtnAdd.Margin = new Thickness(8, 13, width, 7);
+                }
+                else
+                {
+                    if (sizeChange)
+                    {
+                        BtnAdd.Margin = new Thickness(8, 13, width, 7);
+                    }
+                    else
+                    {
+                        sizeChange = false;
+                        BtnAdd.Margin = new Thickness(8, 13, width + 40, 7);
+                    }
+                }
+            }
+
             TabablzControl.UpdateLayout();
         }
 
         private void TxtRename_PreviewKeyDown(object sender, KeyEventArgs e)
         {
-            if(e.Key == Key.Enter)
+            if (e.Key == Key.Enter)
             {
                 TabablzControl.Focus();
             }
@@ -364,10 +401,10 @@ namespace PDF_Master.Views
                 //放在主窗体的显示事件里,避免因网络请求问题导致启动缓慢
                 await Task.Run(() =>
                 {
-                //上传启动信息至服务端
-                ServiceHelper.CreateDeviceLog();
+                    //上传启动信息至服务端
+                    ServiceHelper.CreateDeviceLog();
                 });
             }
         }
     }
-}
+}