public override bool Open() { if (KCommon.CheckVersion(base.EmbeddedEntry.FullName)) { DockWindow dockWindow = System.Windows.Application.Current.MainWindow as DockWindow; if (Setting.IsSingleFile == "1" && Setting.TabsDic.Count > 0) { foreach (KeyValuePair <object, object> item in Setting.TabsDic) { if (((Mainpage)item.Value).FilePath == base.EmbeddedEntry.FullName) { ((LayoutDocument)item.Key).IsActive = true; ((LayoutDocument)item.Key).IsSelected = true; return(true); } } } Mainpage content = new Mainpage(base.EmbeddedEntry.FullName); string title = base.EmbeddedEntry.Name.Substring(0, base.EmbeddedEntry.Name.Length - 4); BitmapImage kFBThumnail = KCommon.GetKFBThumnail(base.EmbeddedEntry.FullName); 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(); return(false); } dockWindow.AddItem(base.EmbeddedEntry.Name + DateTime.Now.ToString("yyyyMMddhhmmss"), title, content, kFBThumnail); return(true); } return(false); }
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()); } }