| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- using System;
- using System.Threading;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using System.Windows.Forms.Integration;
- using Core.Mes.Client.Comm.WPF;
- namespace Core.StlMes
- {
- public partial class Form3 : Form
- {
- private System.Windows.Forms.Integration.ElementHost elementHost1;
- private delegate void TestDlg(System.Windows.Forms.Integration.ElementHost element);
- public Form3()
- {
- InitializeComponent();
- Thread NetServer = new Thread(new ThreadStart(test));
- NetServer.SetApartmentState(ApartmentState.STA);
- NetServer.IsBackground = true;
- //NetServer.Start();
- }
- private void Form3_MouseDoubleClick(object sender, MouseEventArgs e)
- {
- //System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal,
- // new TestDlg(test));
- this.Controls.Add(elementHost1);
- }
- private void test1(System.Windows.Forms.Integration.ElementHost element)
- {
- this.Controls.Add(element);
- }
- private void test()
- {
- if (this.Controls.Contains(Controls["elementHost1"]))
- return;
- Core.Mes.Client.Comm.WPF.DocumentViewer documentViewer1;
- elementHost1 = new System.Windows.Forms.Integration.ElementHost();
- documentViewer1 = new Core.Mes.Client.Comm.WPF.DocumentViewer();
- elementHost1.Dock = System.Windows.Forms.DockStyle.Fill;
- elementHost1.Location = new System.Drawing.Point(0, 0);
- elementHost1.Name = "elementHost1";
- elementHost1.Size = new System.Drawing.Size(763, 417);
- elementHost1.TabIndex = 0;
- elementHost1.Text = "elementHost1";
- elementHost1.Child = documentViewer1;
- String[] args = new String[] { "a" ,"b"};
- MessageBox.Show(ArrayToString(args," "));
- //this.Controls.Add(elementHost1);
- TestDlg dlg = new TestDlg(test1);
- this.Invoke(dlg, new object[] { elementHost1 });
- }
- private string ArrayToString(Array array, string separator)
- {
- string result = "";
- if (array != null && array.Length > 0)
- {
- for (int i = 0; i < array.Length - 1;i++ )
- {
- result += array.GetValue(i).ToString() + separator;
- }
- result += array.GetValue(array.Length-1).ToString();
- }
- return result;
- }
- private void Form3_Load(object sender, EventArgs e)
- {
- }
- }
- }
|