private void btnInput3_Click(object sender, RoutedEventArgs e) { WindowsFormsHostUserControl windowsFormsHostUserControl = new WindowsFormsHostUserControl(); TabItem windowsFormsHostTabItem = new TabItem(); Label headerLabel = new Label(); headerLabel.Content = "外程"; headerLabel.MouseDoubleClick += headerLabel_MouseDoubleClick; windowsFormsHostTabItem.Header = headerLabel; windowsFormsHostTabItem.Content = windowsFormsHostUserControl; applicationTabControl.Items.Add(windowsFormsHostTabItem); applicationTabControl.SelectedItem = windowsFormsHostTabItem; IntPtr handle_application = FindWindow(null, appTextBox3.Text); //IntPtr handle_application = (IntPtr)Convert.ToInt32(appTextBox.Text, 16); windowsFormsHostUserControl.loadProcess2(handle_application); }
private void btnLoadInk_Click(object sender, RoutedEventArgs e) { WindowsFormsHostUserControl host = (WindowsFormsHostUserControl)((TabItem)applicationTabControl.SelectedItem).Content; handle = host.handle_application; ParagraphFigureUserControl paragraphFigureUserControl = new ParagraphFigureUserControl(); //paragraphFigureUserControl.HideToolBar(); TabItem paragraphFigureTabItem = new TabItem(); paragraphFigureTabItem.Header = "图片"; paragraphFigureTabItem.Content = paragraphFigureUserControl; applicationTabControl.Items.Add(paragraphFigureTabItem); applicationTabControl.SelectedItem = paragraphFigureTabItem; //加载图片 System.Drawing.Bitmap bitBmp = MainWindow.PrtWindow(handle); BitmapSource bs = Imaging.CreateBitmapSourceFromHBitmap(bitBmp.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); ImageSource img = bs; paragraphFigureUserControl.img.Source = img; }
public void loadProcess(string processStr) { if (MainWindow.app_included) { WindowsFormsHostUserControl windowsFormsHostUserControl = new WindowsFormsHostUserControl(); windowsFormsHostUserControl.applicationId = application_id; application_id_list.Add(application_id); application_id += 1; TabItem windowsFormsHostTabItem = new TabItem(); Label headerLabel = new Label(); headerLabel.Content = headerStr; headerLabel.MouseDoubleClick += headerLabel_MouseDoubleClick; windowsFormsHostTabItem.Header = headerLabel; windowsFormsHostTabItem.Content = windowsFormsHostUserControl; applicationTabControl.Items.Add(windowsFormsHostTabItem); applicationTabControl.SelectedItem = windowsFormsHostTabItem; try { windowsFormsHostUserControl.loadProcess(processStr); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } } else { Process process = null; try { process = Process.Start(processStr); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } //IntPtr handle_application = (IntPtr)0; //if (process != null) //{ // while ((int)handle_application == 0) // handle_application = process.MainWindowHandle; //} //else //{ // var t = DateTime.Now.AddMilliseconds(1000); // while (DateTime.Now < t) // DispatcherHelper.DoEvents(); // //handle_application = FindWindow("CabinetWClass", null); // handle_application = GetForegroundWindow(); //} ////设置两个窗体的位置 //if (MainWindow.setupUserControl.leftRightRadioButton.IsChecked == true) //{ // MainWindow.mainWindow.rightButton_Click2(); // System.Drawing.Rectangle rect = System.Windows.Forms.Screen.GetWorkingArea(new System.Drawing.Point(0, 0)); // double scaleX = PrimaryScreen.ScaleX; // double scaleY = PrimaryScreen.ScaleY; // double nWidth = rect.Width/2; // double nHeight = rect.Height; // MoveWindow(handle_application, 0, 0, (int)nWidth, (int)nHeight, true); //} } }