瀏覽代碼

Merge branch 'dev' of git.kdan.cc:/Windows/PDFOffice_Windows_exe into dev

OYXH\oyxh 1 年之前
父節點
當前提交
cad47d2b71

+ 79 - 40
PDF Office/App.xaml.cs

@@ -261,45 +261,56 @@ namespace PDF_Master
             if (pros.Length > 1)
             {
                 if (e != null && e.Args != null && e.Args.Length > 0)
-                {
-                    foreach (var filePath in e.Args)
-                    {
-                        if (filePath.ToLower().Contains(".pdf") && Path.GetExtension(filePath).ToLower() == ".pdf")
-                        {
-                            try
-                            {
-                                uint mapSize = 1024;
-                                IntPtr mapHandle = Win32Helper.CreateFileMapping(IntPtr.Zero, IntPtr.Zero, Win32Helper.FileMapProtection.PageReadWrite, 0, mapSize, "Global\\sharePathNotify");
-
-                                if (mapHandle != IntPtr.Zero)
-                                {
-                                    IntPtr writePtr = Win32Helper.MapViewOfFileEx(mapHandle, Win32Helper.FileMapAccessType.Read | Win32Helper.FileMapAccessType.Write, 0, 0, UIntPtr.Zero, IntPtr.Zero);
-                                    Marshal.Copy(filePath.ToCharArray(), 0, writePtr, filePath.Length);
-                                    MD5 currMd5 = MD5.Create();
-                                    byte[] hashArray = currMd5.ComputeHash(Encoding.Default.GetBytes(filePath));
-                                    StringBuilder hexBuilder = new StringBuilder();
-                                    foreach (byte code in hashArray)
-                                    {
-                                        hexBuilder.AppendFormat("{0:X2}", code);
-                                    }
-
-                                    IntPtr waitPtr = Win32Helper.CreateEvent(IntPtr.Zero, true, false, "Global\\shareWaitNotify" + hexBuilder.ToString());
-                                    if (waitPtr != IntPtr.Zero)
-                                    {
-                                        Win32Helper.PostMessage((IntPtr)0xffff, MsgId, IntPtr.Zero, (IntPtr)filePath.Length);
-                                        Win32Helper.WaitForSingleObject(waitPtr, 5000);
-                                        Win32Helper.CloseHandle(waitPtr);
-                                    }
-                                    Win32Helper.UnmapViewOfFile(writePtr);
-                                    Win32Helper.CloseHandle(mapHandle);
-                                }
-                            }
-                            catch
-                            {
-
-                            }
-                        }
+                {
+                    if(Webgoapp(e.Args)==true)
+                    {
+                        Win32Helper.PostMessage((IntPtr)0xffff, WakeId, IntPtr.Zero, IntPtr.Zero);
+                        IntPtr waitPtr = Win32Helper.CreateEvent(IntPtr.Zero, true, false, "Global\\shareWaitNotify" + Guid.NewGuid());
+                        Win32Helper.WaitForSingleObject(waitPtr, 5000);
+                        Win32Helper.CloseHandle(waitPtr);
                     }
+                    else
+                    {
+                        foreach (var filePath in e.Args)
+                        {
+                            if (filePath.ToLower().Contains(".pdf") && Path.GetExtension(filePath).ToLower() == ".pdf")
+                            {
+                                try
+                                {
+                                    uint mapSize = 1024;
+                                    IntPtr mapHandle = Win32Helper.CreateFileMapping(IntPtr.Zero, IntPtr.Zero, Win32Helper.FileMapProtection.PageReadWrite, 0, mapSize, "Global\\sharePathNotify");
+
+                                    if (mapHandle != IntPtr.Zero)
+                                    {
+                                        IntPtr writePtr = Win32Helper.MapViewOfFileEx(mapHandle, Win32Helper.FileMapAccessType.Read | Win32Helper.FileMapAccessType.Write, 0, 0, UIntPtr.Zero, IntPtr.Zero);
+                                        Marshal.Copy(filePath.ToCharArray(), 0, writePtr, filePath.Length);
+                                        MD5 currMd5 = MD5.Create();
+                                        byte[] hashArray = currMd5.ComputeHash(Encoding.Default.GetBytes(filePath));
+                                        StringBuilder hexBuilder = new StringBuilder();
+                                        foreach (byte code in hashArray)
+                                        {
+                                            hexBuilder.AppendFormat("{0:X2}", code);
+                                        }
+
+                                        IntPtr waitPtr = Win32Helper.CreateEvent(IntPtr.Zero, true, false, "Global\\shareWaitNotify" + hexBuilder.ToString());
+                                        if (waitPtr != IntPtr.Zero)
+                                        {
+                                            Win32Helper.PostMessage((IntPtr)0xffff, MsgId, IntPtr.Zero, (IntPtr)filePath.Length);
+                                            Win32Helper.WaitForSingleObject(waitPtr, 5000);
+                                            Win32Helper.CloseHandle(waitPtr);
+                                        }
+                                        Win32Helper.UnmapViewOfFile(writePtr);
+                                        Win32Helper.CloseHandle(mapHandle);
+                                    }
+                                }
+                                catch
+                                {
+
+                                }
+                            }
+                        }
+                    }
+                 
                 }
                 else
                 {
@@ -411,9 +422,37 @@ namespace PDF_Master
                 }
             }
 
-            base.OnStartup(e);
-        }
+            base.OnStartup(e);
+            Webgoapp(e.Args);
 
+        }
+        public static bool Webgoapp(string[] args)
+        {
+            bool flg = false;
+            if (args.Length > 0)
+            {
+                string url = args[0];
+                MessageBox.Show(url);
+                string[] urlParts = url.Split(new char[] { '?', '&' });
+                Dictionary<string, string> parameters = new Dictionary<string, string>();
+
+                foreach (string part in urlParts.Skip(1))
+                {
+                    string[] keyValue = part.Split('=');
+                    if (keyValue.Length == 2)
+                    {
+                        flg = true;
+                        string key = keyValue[0];
+                        string value = Uri.UnescapeDataString(keyValue[1]); // 对参数值进行URL解码
+                        MessageBox.Show(key +":"+ value);
+                    }
+                }
+
+
+
+            }
+            return flg;
+        }
 
         private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
         {

+ 64 - 46
PDF Office/Helper/ServiceHelper.cs

@@ -105,7 +105,7 @@ namespace PDF_Master.Helper
         /// </summary>
         public static string CheckDeviceStatusUrl = "/pdf-office-sso/auth/checkDeviceStatus";
 
-
+        public static string AcceptdataUrl = "http://127.0.0.1:5544";
 
         /// <summary>
         /// 用于检查网络是否可以连接互联网,true表示连接成功,false表示连接失败 
@@ -409,6 +409,7 @@ namespace PDF_Master.Helper
                     JToken jToken;
                     if (jobject.TryGetValue("msg", out jToken) == false)
                     {
+                        //ListenerSubscription();
                         App.IsLogin = true;
                         Settings.Default.UserDate.Email= jobject["email"].ToObject<string>().ToLower();
                         Settings.Default.UserDate.id= jobject["id"].ToObject<string>().ToLower();
@@ -1201,69 +1202,86 @@ namespace PDF_Master.Helper
             catch { }
         }
 
-
-        //监听订阅行为
-        public static void ListenerSubscription()
+        public static void Acceptdata()
         {
-            var listener = new HttpListener();
-            string url = "http://139.196.160.101:8081/";
+            HttpWebResponse response = null;
+            ServicePointManager.DefaultConnectionLimit = 200;
+
+            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(OKcodeUrl);
+            request.Method = "Get";
+            request.ContentType = "text/html;charset=UTF-8";
+            //request.Accept = "application/vnd.api+json;version=1";
+            request.UserAgent = "Apifox/1.0.0 (https://www.apifox.cn)";
+            request.Timeout = 20000;
+            request.ServicePoint.Expect100Continue = false;
             try
             {
-              
-              
-                // 监听的 URL,可以指定多个 URL
-                listener.Prefixes.Add(url);
-                // 启动 HttpListener
-                listener.Start();
-
-                Console.WriteLine("HTTP 服务器已启动,等待请求...");
-
-                // 循环接收请求
-                while (true)
+                response = (HttpWebResponse)request.GetResponse();
+                using (StreamReader reader = new StreamReader(response.GetResponseStream()))
                 {
-                    // 等待请求并获取对应的上下文
-                    var context = listener.GetContext();
+                    string responseData = reader.ReadToEnd();
+                    Console.WriteLine(responseData);
+                    reader.Close();
+                    JObject jobject = (JObject)JsonConvert.DeserializeObject(responseData);
+                    if (response != null)
+                    {
+                        response.Close();
+                    }
+                    if (request != null)
+                    {
+                        request.Abort();
+                    }
+
 
-                    // 处理请求,并返回响应,不需要响应时可以注释
-                    //ProcessRequest(context);
                 }
             }
-            catch (Exception ex)
-            {
-                Console.WriteLine("出现异常:" + ex.Message);
-            }
-            finally
+            catch
             {
-                // 停止 HttpListener
-                listener.Stop();
+
             }
-        }
 
-        //监听数据响应
-        static void ProcessRequest(HttpListenerContext context)
+        }
+        //监听订阅行为
+        public static void ListenerSubscription()
         {
-            // 获取请求对象
-            var request = context.Request;
+            string url = "http://127.0.0.1:5544/"; // 监听的URL地址
+
+            using (HttpListener listener = new HttpListener())
+            {
+                listener.Prefixes.Add(url); // 添加要监听的前缀
 
-            // 获取响应对象
-            var response = context.Response;
+                listener.Start(); // 启动监听
 
-            // 设置响应内容
-            string responseText = "Hello, world!"; // 这里可以根据需要生成动态的响应内容
-            byte[] responseData = System.Text.Encoding.UTF8.GetBytes(responseText);
+                Console.WriteLine("Listening for GET requests on {0}", url);
 
-            // 设置响应头
-            response.ContentType = "text/plain";
-            response.ContentLength64 = responseData.Length;
+                while (true)
+                {
+                    HttpListenerContext context = listener.GetContext();
+
+                    // 处理GET请求
+                    if (context.Request.HttpMethod == "GET")
+                    {
+                        // 获取请求的路径和查询参数
+                        string path = context.Request.Url.AbsolutePath;
+                        string query = context.Request.Url.Query;
 
-            // 写入响应数据
-            response.OutputStream.Write(responseData, 0, responseData.Length);
+                        // 构建响应内容
+                        string responseText = $"Received GET request on {path}{query}";
 
-            // 关闭响应流
-            response.Close();
+                        byte[] responseBytes = System.Text.Encoding.UTF8.GetBytes(responseText);
+                        context.Response.ContentLength64 = responseBytes.Length;
 
-            Console.WriteLine("请求已处理:{0} {1}", request.HttpMethod, request.Url);
+                        // 发送响应
+                        context.Response.OutputStream.Write(responseBytes, 0, responseBytes.Length);
+                    }
+
+                    // 关闭响应
+                    context.Response.Close();
+                }
+            }
         }
+
+
     }
 }
 

+ 2 - 2
PDF Office/MultilingualResources/PDF Office.en.xlf

@@ -631,8 +631,8 @@
           <target state="new">Users have already subscribed to PDF Master</target>
         </trans-unit>
         <trans-unit id="BtnTextContinue" translate="yes" xml:space="preserve">
-          <source>Continue</source>
-          <target state="new">Continue</target>
+          <source>Save and Continue</source>
+          <target state="new">Save and Continue</target>
         </trans-unit>
       </group>
     </body>

+ 2 - 2
PDF Office/MultilingualResources/PDF Office.zh-Hans.xlf

@@ -631,8 +631,8 @@
           <target state="new">Users have already subscribed to PDF Master</target>
         </trans-unit>
         <trans-unit id="BtnTextContinue" translate="yes" xml:space="preserve">
-          <source>Continue</source>
-          <target state="new">Continue</target>
+          <source>Save and Continue</source>
+          <target state="new">Save and Continue</target>
         </trans-unit>
       </group>
     </body>

+ 2 - 2
PDF Office/MultilingualResources/PDF Office.zh-Hant.xlf

@@ -631,8 +631,8 @@
           <target state="new">Users have already subscribed to PDF Master</target>
         </trans-unit>
         <trans-unit id="BtnTextContinue" translate="yes" xml:space="preserve">
-          <source>Continue</source>
-          <target state="new">Continue</target>
+          <source>Save and Continue</source>
+          <target state="new">Save and Continue</target>
         </trans-unit>
       </group>
     </body>

+ 1 - 1
PDF Office/Strings/Service/Service.Designer.cs

@@ -61,7 +61,7 @@ namespace PDF_Master.Strings.Service {
         }
         
         /// <summary>
-        ///   查找类似 Continue 的本地化字符串。
+        ///   查找类似 Save and Continue 的本地化字符串。
         /// </summary>
         public static string BtnTextContinue {
             get {

+ 1 - 1
PDF Office/Strings/Service/Service.resx

@@ -118,7 +118,7 @@
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
   <data name="BtnTextContinue" xml:space="preserve">
-    <value>Continue</value>
+    <value>Save and Continue</value>
   </data>
   <data name="BtnTextSavewithWatermark" xml:space="preserve">
     <value>Save with Watermark</value>

+ 1 - 1
PDF Office/ViewModels/Dialog/ServiceDialog/SubscriptionDialogViewModel.cs

@@ -240,7 +240,7 @@ namespace PDF_Master.ViewModels.Dialog.ServiceDialog
             }
             else 
             {
-               if( viewContentViewModel.saveAsFile(null, IsFormSave)==false)
+               if(viewContentViewModel != null&&viewContentViewModel.saveAsFile(null, IsFormSave)==false)
                 {
                     RequestClose?.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.Cancel));
                 }

+ 5 - 2
PDF Office/ViewModels/MainWindowViewModel.cs

@@ -389,6 +389,7 @@ namespace PDF_Master.ViewModels
                 {
 
                     LoginVis = Visibility.Visible;
+                    RegisterVis = Visibility.Collapsed;
                     OphVis = Visibility.Visible;
                 }
                 else
@@ -401,14 +402,15 @@ namespace PDF_Master.ViewModels
             else if(Settings.Default.UserDate.Email!="")
             {
                 LoginVis = Visibility.Visible;
+                RegisterVis = Visibility.Collapsed;
                 OphVis = Visibility.Visible;
             }
             else
             {
                 RegisterVis = Visibility.Visible;
+                LoginVis = Visibility.Collapsed;
                 OphVis = Visibility.Visible;
             }
-
             InitString();
         }
 
@@ -468,7 +470,8 @@ namespace PDF_Master.ViewModels
             if (Settings.Default.AppProperties.LoginToken != "")
             {
 
-                if (ServiceHelper.GetUser() == "330" || ServiceHelper.GetUser() == "304")
+                string code = ServiceHelper.GetUser();
+                if (code == "330" || code == "304")
                 {
 
                     UserVis = Visibility.Collapsed;

+ 11 - 0
PDF Office/ViewModels/PageEdit/PageEditContentViewModel.cs

@@ -8,6 +8,7 @@ using PDF_Master.Helper;
 using PDF_Master.Model;
 using PDF_Master.Model.HomePageToolsDialogs;
 using PDF_Master.Model.PageEdit;
+using PDF_Master.Properties;
 using PDFReader_WPF.Helper;
 using Prism.Commands;
 using Prism.Events;
@@ -863,6 +864,11 @@ namespace PDF_Master.ViewModels.PageEdit
                     {
                         return;
                     }
+                    //保存并继续,使用了高级功能则弹窗权益弹窗
+                    if (!viewContentViewModel.saveFile(true))
+                    {
+                        return;
+                    }
                     var model = e.Parameters.GetValue<HomePageSplitDialogModel>(ParameterNames.DataModel);
                     DoSplitPages(model);
                 }
@@ -898,6 +904,11 @@ namespace PDF_Master.ViewModels.PageEdit
                     {
                         return;
                     }
+                    //保存并继续,使用了高级功能则弹窗权益弹窗
+                    if (!viewContentViewModel.saveFile(true))
+                    {
+                        return;
+                    }
                     var model = e.Parameters.GetValue<ExtractModel>(ParameterNames.DataModel);
                     DoExtractPages(model.IsEveryPageToFile, model.IsDeleteAfterExtract);
                 }

+ 16 - 2
PDF Office/ViewModels/PropertyPanel/PDFEdit/TextEditPropertyViewModel.cs

@@ -823,14 +823,28 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             CurrentFontFamily = new ComboDataItem(TextEditEvent.FontName, TextEditEvent.FontName);
             FontStyleItem = TextEditEvent.IsItalic ? FontStyles.Italic : FontStyles.Normal;
             FontWeightItem = TextEditEvent.IsBold ? FontWeights.Bold : FontWeights.Normal;
+            //GetCurrentFontFamily(TextEditEvent.FontName, TextEditEvent.FontName);
             GetFontWeights_Style(FontStyleItem, FontWeightItem);
-         
+          
             //判断样式列表中是否存在对应样式
             bool isExist = false;
             foreach (var item in PresetFontList)
             {
+                string itemmFontFamily = item.mFontFamily.Source;
+                if (item.mFontFamily.Source == "Arial")
+                {
+                    itemmFontFamily = "Helvetica";
+                }
+                if (item.mFontFamily.Source == "Times-Roman" || itemmFontFamily == "Times")
+                {
+                    itemmFontFamily = "Times-Roman";
+                }
+                if (item.mFontFamily.Source == "Courier")
+                {
+                    itemmFontFamily = "Courier New";
+                }
                 if (TextEditEvent.FontSize == item.mFontSize && TextEditEvent.IsBold == (item.mFontWeight == FontWeights.Bold) && TextEditEvent.IsItalic == (item.mFontStyle == FontStyles.Italic)
-                    && (TextEditEvent.FontName == item.mFontFamily.Source || TextEditEvent.FontName == "Arial" && item.mFontFamily.Source == "Helvetica")
+                    && (TextEditEvent.FontName == itemmFontFamily || TextEditEvent.FontName == "Arial" && item.mFontFamily.Source == "Helvetica")
                     )
                 {
                     if (item.mTag != "Custom")

+ 6 - 1
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -1933,7 +1933,12 @@ namespace PDF_Master.ViewModels
         }
 
         public void ShowPrintDialog()
-        {
+        { 
+            //保存并继续,使用了高级功能则弹窗权益弹窗
+            if (!saveFile(true))
+            {
+                return;
+            }
             DataTrackingHelper.SendEvent(DataTrackingHelper.EventType.Tbr, "Tbr_Btn", "Btn_Tbr_Print");
             DialogParameters printValue = new DialogParameters();
             printValue.Add(ParameterNames.PDFViewer, PDFViewer);

+ 12 - 8
PDF Office/Views/MainWindow.xaml.cs

@@ -171,22 +171,26 @@ namespace PDF_Master.Views
             App.Current.MainWindow = this;
             App.mainWindowViewModel = this.DataContext as MainWindowViewModel;
             aggregator?.GetEvent<DragablzWindowEvent>().Publish(new DragablzWindowEventArgs() { TabControl = TabablzControl, Type = DragablzWindowEventType.Activated });
-
-            //判断本地有没有token,没有显示登录,有再判断登录状态
-            if (Settings.Default.AppProperties.LoginToken != "")
+            //只需要第一次激活时获取一次信息
+            if(App.IsFirstOpen)
             {
-
-                string code = ServiceHelper.GetUser();
-                if (code == "330" || code == "304")
+                //判断本地有没有token,没有显示登录,有再判断登录状态
+                if (Settings.Default.AppProperties.LoginToken != "")
                 {
 
-                    if (Settings.Default.UserDate.IsLoginoff == false)
+                    string code = ServiceHelper.GetUser();
+                    if (code == "330" || code == "304")
                     {
-                        App.mainWindowViewModel.OpenLoginoff();
+
+                        if (Settings.Default.UserDate.IsLoginoff == false)
+                        {
+                            App.mainWindowViewModel.OpenLoginoff();
+                        }
                     }
                 }
             }
 
+
             //设为默认浏览器后,外部点击文档打开
             if (App.NeedOpenFilePathList.Count != 0)
             {