Esempio n. 1
0
 public static bool CheckVersion(string filepath)
 {
     try
     {
         int num = 11;
         try
         {
             float f = 0f;
             DllImageFuc.GetDllVersionFunc(ref f);
             num = (int)(Math.Round(f, 1) * 10.0);
         }
         catch
         {
         }
         DllImageFuc       dllImageFuc = new DllImageFuc();
         IMAGE_INFO_STRUCT k           = default(IMAGE_INFO_STRUCT);
         k.DataFilePTR = 0;
         dllImageFuc.CkInitImageFileFunc(ref k, filepath);
         float fScale = 0f;
         dllImageFuc.CkGetVersionInfoFunc(ref k, ref fScale);
         int num2 = (int)(fScale * 10f);
         if (num2 > num)
         {
             MessageWind messageWind = new MessageWind(MessageBoxButton.OK, System.Windows.Application.Current.MainWindow, ((DockWindow)System.Windows.Application.Current.MainWindow).languageSetter.LanguageResource["Filedamage2"], ((DockWindow)System.Windows.Application.Current.MainWindow).languageSetter.LanguageResource["Prompt"], MessageBoxIcon.Exclamation, false);
             messageWind.ShowDialog();
             return(false);
         }
         if (num2 == 0)
         {
             MessageWind messageWind2 = new MessageWind(MessageBoxButton.OK, System.Windows.Application.Current.MainWindow, ((DockWindow)System.Windows.Application.Current.MainWindow).languageSetter.LanguageResource["Filedamage"], ((DockWindow)System.Windows.Application.Current.MainWindow).languageSetter.LanguageResource["Prompt"], MessageBoxIcon.Exclamation, false);
             messageWind2.ShowDialog();
             return(false);
         }
         return(true);
     }
     catch (Exception e)
     {
         System.Windows.MessageBox.Show(e.Message);
         MessageWind messageWind3 = new MessageWind(MessageBoxButton.OK, System.Windows.Application.Current.MainWindow, ((DockWindow)System.Windows.Application.Current.MainWindow).languageSetter.LanguageResource["Filedamage2"], ((DockWindow)System.Windows.Application.Current.MainWindow).languageSetter.LanguageResource["Prompt"], MessageBoxIcon.Exclamation, false);
         messageWind3.ShowDialog();
         return(false);
     }
 }
Esempio n. 2
0
 private void App_Startup(object sender, StartupEventArgs e)
 {
     try
     {
         CultureInfo cultureInfo = null;
         if (Thread.CurrentThread.CurrentCulture.Name == "zh-CN")
         {
             Setting.Language = "0";
             cultureInfo      = new CultureInfo("zh-Hans");
         }
         else
         {
             Setting.Language = "1";
             cultureInfo      = new CultureInfo("en-US");
         }
         Thread.CurrentThread.CurrentCulture   = cultureInfo;
         Thread.CurrentThread.CurrentUICulture = cultureInfo;
         MultiLanguage.Culture = cultureInfo;
         singleInstanceWatcher = new Semaphore(0, 1, Assembly.GetExecutingAssembly().GetName().Name, out createdNew);
         string text  = string.Empty;
         string empty = string.Empty;
         if (e.Args.Length > 0)
         {
             empty = e.Args[0].Substring(e.Args[0].LastIndexOf('.'));
             text  = ((empty.ToLower() == ".kfb") ? e.Args[0] : ((empty.ToLower() == ".case") ? e.Args[0].Substring(0, e.Args[0].Length - empty.Length) : ((!(empty.ToLower() == ".ano")) ? e.Args[0] : e.Args[0].Substring(0, e.Args[0].Length - empty.Length))));
         }
         if (createdNew)
         {
             DockWindow dockWindow = new DockWindow();
             if (e.Args.Length == 1)
             {
                 if (File.Exists(text))
                 {
                     if (Setting.IsMutiScreen == "1" && Screen.AllScreens.Length > 1)
                     {
                         dockWindow.WindowState = System.Windows.WindowState.Minimized;
                         Screen    screen      = Screen.AllScreens[Screen.AllScreens.Length - 1];
                         Rectangle workingArea = screen.WorkingArea;
                         dockWindow.Top  = workingArea.Y;
                         dockWindow.Left = workingArea.X;
                     }
                     dockWindow.Show();
                     dockWindow.Left   = 0.0;
                     dockWindow.Top    = 0.0;
                     dockWindow.Height = SystemParameters.WorkArea.Height;
                     dockWindow.Width  = SystemParameters.WorkArea.Width;
                     if (KCommon.CheckVersion(text))
                     {
                         Mainpage content = new Mainpage(text);
                         string   text2   = text.Substring(text.LastIndexOf("\\") + 1, text.Length - text.LastIndexOf("\\") - 1);
                         text2 = text2.Substring(0, text2.Length - 4);
                         BitmapImage kFBThumnail = KCommon.GetKFBThumnail(text);
                         if (kFBThumnail.StreamSource == null)
                         {
                             MessageWind messageWind = new MessageWind(MessageBoxButton.OK, System.Windows.Application.Current.MainWindow, dockWindow.languageSetter.LanguageResource["Filedamage"], dockWindow.languageSetter.LanguageResource["Prompt"], MessageBoxIcon.Exclamation, false);
                             messageWind.ShowDialog();
                             dockWindow.Close();
                         }
                         else
                         {
                             dockWindow.AddItem(text + DateTime.Now.ToString("yyyyMMddhhmmss"), text2, content, kFBThumnail);
                             dockWindow.imgs._evm.SearchViewModel.UIConfirmedParseName = text.Substring(0, text.LastIndexOf("\\"));
                         }
                     }
                 }
                 else
                 {
                     MessageWind messageWind2 = new MessageWind(MessageBoxButton.OK, System.Windows.Application.Current.MainWindow, "文件不存在!", dockWindow.languageSetter.LanguageResource["Prompt"], MessageBoxIcon.Exclamation, false);
                     messageWind2.ShowDialog();
                     dockWindow.Close();
                 }
             }
             else
             {
                 if (Setting.IsMutiScreen == "1" && Screen.AllScreens.Length > 1)
                 {
                     dockWindow.WindowState = System.Windows.WindowState.Minimized;
                     Screen    screen2      = Screen.AllScreens[Screen.AllScreens.Length - 1];
                     Rectangle workingArea2 = screen2.WorkingArea;
                     dockWindow.Top    = workingArea2.Y;
                     dockWindow.Left   = workingArea2.X;
                     dockWindow.Width  = workingArea2.Width;
                     dockWindow.Height = workingArea2.Height;
                 }
                 dockWindow.Show();
                 dockWindow.Left   = 0.0;
                 dockWindow.Top    = 0.0;
                 dockWindow.Height = SystemParameters.WorkArea.Height;
                 dockWindow.Width  = SystemParameters.WorkArea.Width;
                 dockWindow.imagelist.Show();
             }
         }
         else
         {
             Process   currentProcess  = Process.GetCurrentProcess();
             Process   proc            = null;
             Process[] processesByName = Process.GetProcessesByName(currentProcess.ProcessName);
             foreach (Process process in processesByName)
             {
                 if (process.Id != currentProcess.Id)
                 {
                     NativeMethods.ShowWindow(process.MainWindowHandle, WindowShowStyle.ShowNormal);
                     NativeMethods.SetForegroundWindow(process.MainWindowHandle);
                     proc = process;
                     break;
                 }
             }
             if (text.Length > 0)
             {
                 writetemp(text);
                 PostMessage(proc, text);
             }
             Environment.Exit(0);
         }
     }
     catch (Exception ex)
     {
         Xceed.Wpf.Toolkit.MessageBox.Show(ex.ToString());
     }
 }