| | |
| | | public View1() |
| | | { |
| | | InitializeComponent(); |
| | | #region éå¶è¿è¡å®ä¾æ°é |
| | | #region éå¶è¿è¡å®ä¾æ°é |
| | | System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcessesByName("AuxAllWCS"); |
| | | if (processes.Length > System.Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["InstanceLimit"])) |
| | | { |
| | | System.Windows.MessageBox.Show("è¿è¡å¤±è´¥:è¿è¡å®ä¾æ°éå·²è¶
åºéå¶"); |
| | | this.Close(); |
| | | } |
| | | #endregion |
| | | this.DataContext = ViewModel.CreateInstance(this,typeof(View1)); |
| | | #endregion |
| | | this.DataContext = ViewModel.CreateInstance(this, typeof(View1)); |
| | | this.Loaded += (this.DataContext as ViewModel).View1_LoadEvent; |
| | | this.Closing += (this.DataContext as ViewModel).View1_CloseEvent; |
| | | this.Closing += (this.DataContext as ViewModel).View1_CloseEvent; |
| | | commmd(); |
| | | } |
| | | |
| | | public async void commmd() |
| | | { |
| | | await webView.EnsureCoreWebView2Async(); |
| | | |
| | | labbb: |
| | | if (!string.IsNullOrEmpty(HttpServer._listenerPrefix)) |
| | | if (webView.Source != new Uri(HttpServer._listenerPrefix)) |
| | | { |
| | | webView.CoreWebView2.Navigate(HttpServer._listenerPrefix + "/index.html"); |
| | | goto EndInit; |
| | | } |
| | | System.Threading.Thread.Sleep(2000); |
| | | goto labbb; |
| | | EndInit: |
| | | Console.WriteLine("end Set Uri"); |
| | | webView.PreviewKeyDown += (object sender, KeyEventArgs e) => |
| | | { |
| | | // æ£æ¥æä¸ç鮿¯å¦æ¯ F12ï¼å¦ææ¯ï¼ç¦æ¢å
¶é»è®¤è¡ä¸º |
| | | if (e.Key == Key.F12) |
| | | { |
| | | e.Handled = true; |
| | | } |
| | | }; |
| | | await webView.CoreWebView2.ExecuteScriptAsync( |
| | | @" |
| | | document.addEventListener('contextmenu', function(event) { |
| | | event.preventDefault(); |
| | | }, false); |
| | | " |
| | | ); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |