diff --git a/StreamViewer.Designer.cs b/StreamViewer.Designer.cs index 5e0d173..20dcb7f 100644 --- a/StreamViewer.Designer.cs +++ b/StreamViewer.Designer.cs @@ -37,51 +37,23 @@ namespace robospot_camera_finder timerUpdateZoom = new System.Windows.Forms.Timer(components); btnZoomMin = new Button(); btnZoomMax = new Button(); - grpSACN = new GroupBox(); - gbPresetBtns = new GroupBox(); - btnPresetClr = new Button(); - btnPresetRec = new Button(); - btnPreset4 = new Button(); - btnPreset3 = new Button(); - btnPreset2 = new Button(); - btnPreset1 = new Button(); - cbEnableSACN = new CheckBox(); - tbTilt = new TrackBar(); - cbEnableXboxCtrl = new CheckBox(); - tbPan = new TrackBar(); - label2 = new Label(); - numDMXAddr = new NumericUpDown(); - label1 = new Label(); - numUniv = new NumericUpDown(); - timerDMX = new System.Windows.Forms.Timer(components); - splitContainerMain = new SplitContainer(); + tbRtspLink = new TextBox(); + lblRtspLink = new Label(); labelSerial = new Label(); tbSerial = new TextBox(); - btnSidePanel = new Button(); - lblRtspLink = new Label(); - tbRtspLink = new TextBox(); ((System.ComponentModel.ISupportInitialize)videoView).BeginInit(); ((System.ComponentModel.ISupportInitialize)tbZoom).BeginInit(); - grpSACN.SuspendLayout(); - gbPresetBtns.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)tbTilt).BeginInit(); - ((System.ComponentModel.ISupportInitialize)tbPan).BeginInit(); - ((System.ComponentModel.ISupportInitialize)numDMXAddr).BeginInit(); - ((System.ComponentModel.ISupportInitialize)numUniv).BeginInit(); - ((System.ComponentModel.ISupportInitialize)splitContainerMain).BeginInit(); - splitContainerMain.Panel1.SuspendLayout(); - splitContainerMain.Panel2.SuspendLayout(); - splitContainerMain.SuspendLayout(); SuspendLayout(); // // videoView // videoView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; videoView.BackColor = Color.Black; - videoView.Location = new Point(12, 12); + videoView.Location = new Point(13, 14); + videoView.Margin = new Padding(4, 5, 4, 5); videoView.MediaPlayer = null; videoView.Name = "videoView"; - videoView.Size = new Size(730, 453); + videoView.Size = new Size(1035, 796); videoView.TabIndex = 0; videoView.TabStop = false; videoView.Text = "videoView"; @@ -90,11 +62,12 @@ namespace robospot_camera_finder // tbZoom.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right; tbZoom.LargeChange = 20; - tbZoom.Location = new Point(748, 31); + tbZoom.Location = new Point(1056, 58); + tbZoom.Margin = new Padding(4, 5, 4, 5); tbZoom.Maximum = 9999; tbZoom.Name = "tbZoom"; tbZoom.Orientation = Orientation.Vertical; - tbZoom.Size = new Size(45, 416); + tbZoom.Size = new Size(69, 710); tbZoom.SmallChange = 10; tbZoom.TabIndex = 1; tbZoom.TickFrequency = 300; @@ -113,9 +86,10 @@ namespace robospot_camera_finder // btnZoomMin.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; btnZoomMin.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); - btnZoomMin.Location = new Point(748, 442); + btnZoomMin.Location = new Point(1056, 778); + btnZoomMin.Margin = new Padding(4, 5, 4, 5); btnZoomMin.Name = "btnZoomMin"; - btnZoomMin.Size = new Size(42, 23); + btnZoomMin.Size = new Size(60, 38); btnZoomMin.TabIndex = 2; btnZoomMin.Text = "1x"; btnZoomMin.UseVisualStyleBackColor = true; @@ -125,317 +99,80 @@ namespace robospot_camera_finder // btnZoomMax.Anchor = AnchorStyles.Top | AnchorStyles.Right; btnZoomMax.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); - btnZoomMax.Location = new Point(748, 3); + btnZoomMax.Location = new Point(1056, 10); + btnZoomMax.Margin = new Padding(4, 5, 4, 5); btnZoomMax.Name = "btnZoomMax"; - btnZoomMax.Size = new Size(42, 23); + btnZoomMax.Size = new Size(60, 38); btnZoomMax.TabIndex = 3; btnZoomMax.Text = "32x"; btnZoomMax.UseVisualStyleBackColor = true; btnZoomMax.Click += btnZoomMax_Click; // - // grpSACN + // tbRtspLink // - grpSACN.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right; - grpSACN.Controls.Add(gbPresetBtns); - grpSACN.Controls.Add(cbEnableSACN); - grpSACN.Controls.Add(tbTilt); - grpSACN.Controls.Add(cbEnableXboxCtrl); - grpSACN.Controls.Add(tbPan); - grpSACN.Controls.Add(label2); - grpSACN.Controls.Add(numDMXAddr); - grpSACN.Controls.Add(label1); - grpSACN.Controls.Add(numUniv); - grpSACN.Location = new Point(12, 3); - grpSACN.Name = "grpSACN"; - grpSACN.Size = new Size(236, 508); - grpSACN.TabIndex = 4; - grpSACN.TabStop = false; - grpSACN.Text = "sACN Control"; + tbRtspLink.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + tbRtspLink.Location = new Point(573, 820); + tbRtspLink.Margin = new Padding(4, 5, 4, 5); + tbRtspLink.Name = "tbRtspLink"; + tbRtspLink.ReadOnly = true; + tbRtspLink.Size = new Size(545, 31); + tbRtspLink.TabIndex = 8; // - // gbPresetBtns + // lblRtspLink // - gbPresetBtns.Controls.Add(btnPresetClr); - gbPresetBtns.Controls.Add(btnPresetRec); - gbPresetBtns.Controls.Add(btnPreset4); - gbPresetBtns.Controls.Add(btnPreset3); - gbPresetBtns.Controls.Add(btnPreset2); - gbPresetBtns.Controls.Add(btnPreset1); - gbPresetBtns.Location = new Point(6, 287); - gbPresetBtns.Name = "gbPresetBtns"; - gbPresetBtns.Size = new Size(224, 94); - gbPresetBtns.TabIndex = 7; - gbPresetBtns.TabStop = false; - gbPresetBtns.Text = "Presets"; - // - // btnPresetClr - // - btnPresetClr.Enabled = false; - btnPresetClr.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); - btnPresetClr.Location = new Point(113, 56); - btnPresetClr.Name = "btnPresetClr"; - btnPresetClr.Size = new Size(103, 28); - btnPresetClr.TabIndex = 5; - btnPresetClr.Text = "Clear"; - btnPresetClr.UseVisualStyleBackColor = true; - btnPresetClr.Click += btnPresetClr_Click; - // - // btnPresetRec - // - btnPresetRec.Enabled = false; - btnPresetRec.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); - btnPresetRec.Location = new Point(5, 56); - btnPresetRec.Name = "btnPresetRec"; - btnPresetRec.Size = new Size(103, 28); - btnPresetRec.TabIndex = 4; - btnPresetRec.Text = "Record"; - btnPresetRec.UseVisualStyleBackColor = true; - btnPresetRec.Click += btnPresetRec_Click; - // - // btnPreset4 - // - btnPreset4.Enabled = false; - btnPreset4.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); - btnPreset4.Location = new Point(167, 22); - btnPreset4.Name = "btnPreset4"; - btnPreset4.Size = new Size(49, 28); - btnPreset4.TabIndex = 3; - btnPreset4.Text = "4"; - btnPreset4.UseVisualStyleBackColor = true; - btnPreset4.Click += btnPreset4_Click; - // - // btnPreset3 - // - btnPreset3.Enabled = false; - btnPreset3.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); - btnPreset3.Location = new Point(113, 22); - btnPreset3.Name = "btnPreset3"; - btnPreset3.Size = new Size(49, 28); - btnPreset3.TabIndex = 2; - btnPreset3.Text = "3"; - btnPreset3.UseVisualStyleBackColor = true; - btnPreset3.Click += btnPreset3_Click; - // - // btnPreset2 - // - btnPreset2.Enabled = false; - btnPreset2.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); - btnPreset2.Location = new Point(59, 22); - btnPreset2.Name = "btnPreset2"; - btnPreset2.Size = new Size(49, 28); - btnPreset2.TabIndex = 1; - btnPreset2.Text = "2"; - btnPreset2.UseVisualStyleBackColor = true; - btnPreset2.Click += btnPreset2_Click; - // - // btnPreset1 - // - btnPreset1.Enabled = false; - btnPreset1.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); - btnPreset1.Location = new Point(5, 22); - btnPreset1.Name = "btnPreset1"; - btnPreset1.Size = new Size(49, 28); - btnPreset1.TabIndex = 0; - btnPreset1.Text = "1"; - btnPreset1.UseVisualStyleBackColor = true; - btnPreset1.Click += btnPreset1_Click; - // - // cbEnableSACN - // - cbEnableSACN.AutoSize = true; - cbEnableSACN.Location = new Point(19, 22); - cbEnableSACN.Name = "cbEnableSACN"; - cbEnableSACN.Size = new Size(117, 19); - cbEnableSACN.TabIndex = 6; - cbEnableSACN.Text = "Enable sACN Out"; - cbEnableSACN.UseVisualStyleBackColor = true; - cbEnableSACN.CheckedChanged += cbEnableSACN_CheckedChanged; - // - // tbTilt - // - tbTilt.Enabled = false; - tbTilt.Location = new Point(19, 131); - tbTilt.Maximum = 65535; - tbTilt.Name = "tbTilt"; - tbTilt.Orientation = Orientation.Vertical; - tbTilt.Size = new Size(45, 150); - tbTilt.TabIndex = 5; - tbTilt.TickFrequency = 10; - tbTilt.Value = 32768; - // - // cbEnableXboxCtrl - // - cbEnableXboxCtrl.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; - cbEnableXboxCtrl.AutoSize = true; - cbEnableXboxCtrl.Enabled = false; - cbEnableXboxCtrl.Location = new Point(19, 480); - cbEnableXboxCtrl.Name = "cbEnableXboxCtrl"; - cbEnableXboxCtrl.Size = new Size(152, 19); - cbEnableXboxCtrl.TabIndex = 5; - cbEnableXboxCtrl.Text = "Enable Xbox360 Control"; - cbEnableXboxCtrl.UseVisualStyleBackColor = true; - // - // tbPan - // - tbPan.Enabled = false; - tbPan.Location = new Point(70, 184); - tbPan.Maximum = 65535; - tbPan.Name = "tbPan"; - tbPan.Size = new Size(150, 45); - tbPan.TabIndex = 4; - tbPan.TickFrequency = 10; - tbPan.Value = 32768; - // - // label2 - // - label2.AutoSize = true; - label2.Location = new Point(26, 98); - label2.Name = "label2"; - label2.Size = new Size(78, 15); - label2.TabIndex = 3; - label2.Text = "DMX Address"; - label2.TextAlign = ContentAlignment.MiddleRight; - // - // numDMXAddr - // - numDMXAddr.Enabled = false; - numDMXAddr.Location = new Point(110, 96); - numDMXAddr.Maximum = new decimal(new int[] { 504, 0, 0, 0 }); - numDMXAddr.Minimum = new decimal(new int[] { 1, 0, 0, 0 }); - numDMXAddr.Name = "numDMXAddr"; - numDMXAddr.Size = new Size(120, 23); - numDMXAddr.TabIndex = 2; - numDMXAddr.Value = new decimal(new int[] { 1, 0, 0, 0 }); - numDMXAddr.ValueChanged += numDMXAddr_ValueChanged; - // - // label1 - // - label1.AutoSize = true; - label1.Location = new Point(19, 69); - label1.Name = "label1"; - label1.Size = new Size(85, 15); - label1.TabIndex = 1; - label1.Text = "sACN Universe"; - label1.TextAlign = ContentAlignment.MiddleRight; - // - // numUniv - // - numUniv.Enabled = false; - numUniv.Location = new Point(110, 67); - numUniv.Maximum = new decimal(new int[] { 63999, 0, 0, 0 }); - numUniv.Minimum = new decimal(new int[] { 1, 0, 0, 0 }); - numUniv.Name = "numUniv"; - numUniv.Size = new Size(120, 23); - numUniv.TabIndex = 0; - numUniv.Value = new decimal(new int[] { 1, 0, 0, 0 }); - // - // timerDMX - // - timerDMX.Tick += timerDMX_Tick; - // - // splitContainerMain - // - splitContainerMain.Dock = DockStyle.Fill; - splitContainerMain.Location = new Point(0, 0); - splitContainerMain.Name = "splitContainerMain"; - // - // splitContainerMain.Panel1 - // - splitContainerMain.Panel1.Controls.Add(tbRtspLink); - splitContainerMain.Panel1.Controls.Add(lblRtspLink); - splitContainerMain.Panel1.Controls.Add(labelSerial); - splitContainerMain.Panel1.Controls.Add(tbSerial); - splitContainerMain.Panel1.Controls.Add(btnSidePanel); - splitContainerMain.Panel1.Controls.Add(btnZoomMin); - splitContainerMain.Panel1.Controls.Add(tbZoom); - splitContainerMain.Panel1.Controls.Add(btnZoomMax); - splitContainerMain.Panel1.Controls.Add(videoView); - splitContainerMain.Panel1MinSize = 800; - // - // splitContainerMain.Panel2 - // - splitContainerMain.Panel2.Controls.Add(grpSACN); - splitContainerMain.Size = new Size(1064, 514); - splitContainerMain.SplitterDistance = 800; - splitContainerMain.TabIndex = 6; - splitContainerMain.TabStop = false; + lblRtspLink.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + lblRtspLink.AutoSize = true; + lblRtspLink.Location = new Point(478, 823); + lblRtspLink.Margin = new Padding(4, 0, 4, 0); + lblRtspLink.Name = "lblRtspLink"; + lblRtspLink.Size = new Size(87, 25); + lblRtspLink.TabIndex = 7; + lblRtspLink.Text = "RTSP Link"; // // labelSerial // labelSerial.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; labelSerial.AutoSize = true; - labelSerial.Location = new Point(12, 483); + labelSerial.Location = new Point(13, 823); + labelSerial.Margin = new Padding(4, 0, 4, 0); labelSerial.Name = "labelSerial"; - labelSerial.Size = new Size(82, 15); + labelSerial.Size = new Size(124, 25); labelSerial.TabIndex = 6; labelSerial.Text = "Serial Number"; // // tbSerial // tbSerial.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; - tbSerial.Location = new Point(100, 479); + tbSerial.Location = new Point(145, 820); + tbSerial.Margin = new Padding(4, 5, 4, 5); tbSerial.Name = "tbSerial"; tbSerial.ReadOnly = true; - tbSerial.Size = new Size(170, 23); + tbSerial.Size = new Size(241, 31); tbSerial.TabIndex = 5; // - // btnSidePanel - // - btnSidePanel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; - btnSidePanel.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); - btnSidePanel.Location = new Point(748, 479); - btnSidePanel.Name = "btnSidePanel"; - btnSidePanel.Size = new Size(42, 23); - btnSidePanel.TabIndex = 4; - btnSidePanel.Text = ">>"; - btnSidePanel.UseVisualStyleBackColor = true; - btnSidePanel.Click += btnSidePanel_Click; - // - // lblRtspLink - // - lblRtspLink.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; - lblRtspLink.AutoSize = true; - lblRtspLink.Location = new Point(296, 483); - lblRtspLink.Name = "lblRtspLink"; - lblRtspLink.Size = new Size(57, 15); - lblRtspLink.TabIndex = 7; - lblRtspLink.Text = "RTSP Link"; - // - // tbRtspLink - // - tbRtspLink.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; - tbRtspLink.Location = new Point(359, 480); - tbRtspLink.Name = "tbRtspLink"; - tbRtspLink.ReadOnly = true; - tbRtspLink.Size = new Size(383, 23); - tbRtspLink.TabIndex = 8; - // // StreamViewer // - AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleDimensions = new SizeF(10F, 25F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(1064, 514); - Controls.Add(splitContainerMain); + ClientSize = new Size(1138, 857); + Controls.Add(tbRtspLink); + Controls.Add(lblRtspLink); + Controls.Add(videoView); + Controls.Add(labelSerial); + Controls.Add(btnZoomMax); + Controls.Add(tbSerial); + Controls.Add(tbZoom); + Controls.Add(btnZoomMin); Icon = (Icon)resources.GetObject("$this.Icon"); - Margin = new Padding(4, 3, 4, 3); - MinimumSize = new Size(1080, 553); + Margin = new Padding(6, 5, 6, 5); + MinimumSize = new Size(1160, 884); Name = "StreamViewer"; Text = "Camera"; FormClosed += StreamViewer_FormClosed; ((System.ComponentModel.ISupportInitialize)videoView).EndInit(); ((System.ComponentModel.ISupportInitialize)tbZoom).EndInit(); - grpSACN.ResumeLayout(false); - grpSACN.PerformLayout(); - gbPresetBtns.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)tbTilt).EndInit(); - ((System.ComponentModel.ISupportInitialize)tbPan).EndInit(); - ((System.ComponentModel.ISupportInitialize)numDMXAddr).EndInit(); - ((System.ComponentModel.ISupportInitialize)numUniv).EndInit(); - splitContainerMain.Panel1.ResumeLayout(false); - splitContainerMain.Panel1.PerformLayout(); - splitContainerMain.Panel2.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)splitContainerMain).EndInit(); - splitContainerMain.ResumeLayout(false); ResumeLayout(false); + PerformLayout(); } #endregion @@ -445,27 +182,8 @@ namespace robospot_camera_finder private System.Windows.Forms.Timer timerUpdateZoom; private Button btnZoomMin; private Button btnZoomMax; - private GroupBox grpSACN; - private TrackBar tbTilt; - private TrackBar tbPan; - private Label label2; - private NumericUpDown numDMXAddr; - private Label label1; - private NumericUpDown numUniv; - private System.Windows.Forms.Timer timerDMX; - private CheckBox cbEnableXboxCtrl; - private SplitContainer splitContainerMain; - private CheckBox cbEnableSACN; - private Button btnSidePanel; private Label labelSerial; private TextBox tbSerial; - private GroupBox gbPresetBtns; - private Button btnPreset1; - private Button btnPresetClr; - private Button btnPresetRec; - private Button btnPreset4; - private Button btnPreset3; - private Button btnPreset2; private TextBox tbRtspLink; private Label lblRtspLink; } diff --git a/StreamViewer.cs b/StreamViewer.cs index 79a7835..6f6c7a3 100644 --- a/StreamViewer.cs +++ b/StreamViewer.cs @@ -1,7 +1,5 @@ -using Haukcode.sACN; -using LibVLCSharp.Shared; +using LibVLCSharp.Shared; using System.Net; -using XboxController; namespace robospot_camera_finder { @@ -10,44 +8,11 @@ namespace robospot_camera_finder public LibVLC _libVLC; public MediaPlayer _mp; - private static readonly Guid acnSourceId = new Guid("{B32625A6-C280-4389-BD25-E0D13F5B50E0}"); - private static readonly string acnSourceName = "RoboSpotCamViewer"; - - static SACNClient sendClient = new SACNClient(senderId: acnSourceId, senderName: acnSourceName, localAddress: SACNCommon.GetFirstBindAddress().IPAddress); - string cam_ip = ""; int max_zoom_pulse = 9999; int min_zoom_pulse = 10; - byte[] dmx_universe = new byte[512]; - - Xbox360Controller controller = new Xbox360Controller(); - - bool preset_rec_mode = false; - bool preset_clear_mode = false; - - bool preset1_exists = false; - int preset1_pan; - int preset1_tilt; - int preset1_zoom; - - bool preset2_exists = false; - int preset2_pan; - int preset2_tilt; - int preset2_zoom; - - bool preset3_exists = false; - int preset3_pan; - int preset3_tilt; - int preset3_zoom; - - - bool preset4_exists = false; - int preset4_pan; - int preset4_tilt; - int preset4_zoom; - public StreamViewer(string name, string ip, MainForm.Camera camera, MainForm mainForm) { InitializeComponent(); @@ -55,8 +20,6 @@ namespace robospot_camera_finder _libVLC = new LibVLC(); _mp = new MediaPlayer(_libVLC); - splitContainerMain.Panel2Collapsed = true; - cam_ip = ip; this.Text = name; @@ -117,8 +80,6 @@ namespace robospot_camera_finder _mp.Stop(); _mp.Dispose(); _libVLC.Dispose(); - - sendClient.Dispose(); } private void tbZoom_KeyUp(object sender, KeyEventArgs e) @@ -147,319 +108,5 @@ namespace robospot_camera_finder tbZoom.Value = min_zoom_pulse; sendZoomValue(tbZoom.Value.ToString()); } - - - private void timerDMX_Tick(object sender, EventArgs e) - { - controller.update(); - - if (!controller.connected) - { - cbEnableXboxCtrl.Checked = false; - cbEnableXboxCtrl.Enabled = false; - } - else - { - cbEnableXboxCtrl.Enabled = true; - } - - if (cbEnableXboxCtrl.Checked) - { - Point ls = controller.leftThumb; - Point rs = controller.rightThumb; - - bool fast_pt = controller.buttons.LeftStick; - - if ((tbPan.Value + ls.X) < 0) - { - tbPan.Value = 0; - } - else if ((tbPan.Value + ls.X) > 65535) - { - tbPan.Value = 65535; - } - else - { - if (fast_pt) - { - tbPan.Value += (ls.X) * 5; - } - else - { - tbPan.Value += ls.X; - } - } - - if ((tbTilt.Value + ls.Y) < 0) - { - tbTilt.Value = 0; - } - else if ((tbTilt.Value + ls.Y) > 65535) - { - tbTilt.Value = 65535; - } - else - { - if (fast_pt) - { - tbTilt.Value += (ls.Y) * 5; - } - else - { - tbTilt.Value += ls.Y; - } - } - - sendZoomValueManual(rs.Y.ToString()); - - - if (controller.buttons.LB) - { - tbZoom.Value = min_zoom_pulse; - sendZoomValue(tbZoom.Value.ToString()); - } - if (controller.buttons.RB) - { - tbZoom.Value = max_zoom_pulse; - sendZoomValue(tbZoom.Value.ToString()); - } - } - - byte[] pan = BitConverter.GetBytes(tbPan.Value); - byte[] tilt = BitConverter.GetBytes(tbTilt.Value); - int dmx_addr = int.Parse(numDMXAddr.Value.ToString()); - - dmx_universe[dmx_addr - 1] = pan[1]; - dmx_universe[dmx_addr] = pan[0]; - dmx_universe[dmx_addr + 1] = tilt[1]; - dmx_universe[dmx_addr + 2] = tilt[0]; - - sendClient.SendMulticast(Convert.ToUInt16(numUniv.Value.ToString()), dmx_universe); - } - - private void numDMXAddr_ValueChanged(object sender, EventArgs e) - { - tbPan.Value = 32767; - tbTilt.Value = 32767; - - for (int i = 0; i < dmx_universe.Length; i++) - { - dmx_universe[i] = 0; - } - } - - private void cbEnableSACN_CheckedChanged(object sender, EventArgs e) - { - if (cbEnableSACN.Checked) - { - timerDMX.Start(); - - tbPan.Enabled = true; - tbTilt.Enabled = true; - numDMXAddr.Enabled = true; - numUniv.Enabled = true; - btnPreset1.Enabled = true; - btnPreset2.Enabled = true; - btnPreset3.Enabled = true; - btnPreset4.Enabled = true; - btnPresetClr.Enabled = true; - btnPresetRec.Enabled = true; - } - else - { - timerDMX.Stop(); - - tbPan.Enabled = false; - tbTilt.Enabled = false; - numDMXAddr.Enabled = false; - numUniv.Enabled = false; - cbEnableXboxCtrl.Checked = false; - cbEnableXboxCtrl.Enabled = false; - - btnPreset1.Enabled = false; - btnPreset2.Enabled = false; - btnPreset3.Enabled = false; - btnPreset4.Enabled = false; - btnPresetClr.Enabled = false; - btnPresetRec.Enabled = false; - } - } - - private void btnSidePanel_Click(object sender, EventArgs e) - { - if (splitContainerMain.Panel2Collapsed) - { - splitContainerMain.Panel2Collapsed = false; - } - else - { - splitContainerMain.Panel2Collapsed = true; - } - } - - private void btnPresetRec_Click(object sender, EventArgs e) - { - rec_mode_toggle(); - } - - private void rec_mode_toggle() - { - if (preset_clear_mode) - { - preset_clear_mode = false; - btnPresetClr.ForeColor = default(Color); - } - - if (preset_rec_mode) - { - preset_rec_mode = false; - btnPresetRec.ForeColor = default(Color); - } - else - { - preset_rec_mode = true; - btnPresetRec.ForeColor = Color.Red; - } - } - - private void btnPresetClr_Click(object sender, EventArgs e) - { - clear_mode_toggle(); - } - - private void clear_mode_toggle() - { - if (preset_rec_mode) - { - preset_rec_mode = false; - btnPresetRec.ForeColor = default(Color); - } - - if (preset_clear_mode) - { - preset_clear_mode = false; - btnPresetClr.ForeColor = default(Color); - } - else - { - preset_clear_mode = true; - btnPresetClr.ForeColor = Color.Red; - } - } - - private void btnPreset1_Click(object sender, EventArgs e) - { - if (preset_rec_mode) - { - preset1_exists = true; - preset1_pan = tbPan.Value; - preset1_tilt = tbTilt.Value; - preset1_zoom = tbZoom.Value; - btnPreset1.ForeColor = Color.Blue; - rec_mode_toggle(); - } - else if (preset_clear_mode) - { - preset1_exists = false; - preset1_pan = 0; - preset1_tilt = 0; - preset1_zoom = 0; - btnPreset1.ForeColor = default(Color); - clear_mode_toggle(); - } - else if (preset1_exists) - { - tbPan.Value = preset1_pan; - tbTilt.Value = preset1_tilt; - tbZoom.Value = preset1_zoom; - sendZoomValue(tbZoom.Value.ToString()); - } - } - private void btnPreset2_Click(object sender, EventArgs e) - { - if (preset_rec_mode) - { - preset2_exists = true; - preset2_pan = tbPan.Value; - preset2_tilt = tbTilt.Value; - preset2_zoom = tbZoom.Value; - btnPreset2.ForeColor = Color.Blue; - rec_mode_toggle(); - } - else if (preset_clear_mode) - { - preset2_exists = false; - preset2_pan = 0; - preset2_tilt = 0; - preset2_zoom = 0; - btnPreset2.ForeColor = default(Color); - clear_mode_toggle(); - } - else if (preset2_exists) - { - tbPan.Value = preset2_pan; - tbTilt.Value = preset2_tilt; - tbZoom.Value = preset2_zoom; - sendZoomValue(tbZoom.Value.ToString()); - } - } - - private void btnPreset3_Click(object sender, EventArgs e) - { - if (preset_rec_mode) - { - preset3_exists = true; - preset3_pan = tbPan.Value; - preset3_tilt = tbTilt.Value; - preset3_zoom = tbZoom.Value; - btnPreset3.ForeColor = Color.Blue; - rec_mode_toggle(); - } - else if (preset_clear_mode) - { - preset3_exists = false; - preset3_pan = 0; - preset3_tilt = 0; - preset3_zoom = 0; - btnPreset3.ForeColor = default(Color); - clear_mode_toggle(); - } - else if (preset3_exists) - { - tbPan.Value = preset3_pan; - tbTilt.Value = preset3_tilt; - tbZoom.Value = preset3_zoom; - sendZoomValue(tbZoom.Value.ToString()); - } - } - - private void btnPreset4_Click(object sender, EventArgs e) - { - if (preset_rec_mode) - { - preset4_exists = true; - preset4_pan = tbPan.Value; - preset4_tilt = tbTilt.Value; - preset4_zoom = tbZoom.Value; - btnPreset4.ForeColor = Color.Blue; - rec_mode_toggle(); - } - else if (preset_clear_mode) - { - preset4_exists = false; - preset4_pan = 0; - preset4_tilt = 0; - preset4_zoom = 0; - btnPreset4.ForeColor = default(Color); - clear_mode_toggle(); - } - else if (preset4_exists) - { - tbPan.Value = preset4_pan; - tbTilt.Value = preset4_tilt; - tbZoom.Value = preset4_zoom; - sendZoomValue(tbZoom.Value.ToString()); - } - } } } diff --git a/StreamViewer.resx b/StreamViewer.resx index c4d5e00..8dba33d 100644 --- a/StreamViewer.resx +++ b/StreamViewer.resx @@ -120,9 +120,6 @@ 17, 17 - - 169, 17 - diff --git a/Xbox360Controller.cs b/Xbox360Controller.cs deleted file mode 100644 index 5205105..0000000 --- a/Xbox360Controller.cs +++ /dev/null @@ -1,134 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Drawing; - -using SharpDX.XInput; - - -// A class to interface with an xbox 360 controller -namespace XboxController { - class Xbox360Controller { - public struct Buttons { - public bool A; - public bool B; - public bool X; - public bool Y; - public bool LB; - public bool RB; - public bool LeftStick; - public bool RightStick; - public bool Back; - public bool Start; - public bool DLeft; - public bool DUp; - public bool DRight; - public bool DDown; - } - - // Public variables - public Buttons buttons; - public Point leftThumb = new Point(0, 0); - public Point rightThumb = new Point(0, 0); - public bool connected = false; - public int deadband = 2500; - public float leftTrigger = 0; - public float rightTrigger = 0; - public int leftVibration = 0; - public int rightVibration = 0; - public string batteryLevel = ""; - public string batteryType = ""; - public Color batteryColor; - - // private variables - private Controller controller; - private Gamepad gamepad; - private Vibration vibration; - private BatteryInformation batteryInfo; - - // Constructor - public Xbox360Controller() { - controller = new Controller(UserIndex.One); - } - - // Updates the public variables - public void update() { - - // Make sure controller is connected - try { - connected = controller.IsConnected; - } catch (Exception err) { return; } - if(connected == false) { return; } - - // Helper variables - gamepad = controller.GetState().Gamepad; - GamepadButtonFlags btns = controller.GetState().Gamepad.Buttons; - batteryInfo = controller.GetBatteryInformation(BatteryDeviceType.Gamepad); - - - // Thumbsticks - leftThumb.X = Convert.ToInt32((Math.Abs((float)gamepad.LeftThumbX) < deadband) ? 0 : (float)gamepad.LeftThumbX / short.MinValue * -100); - leftThumb.Y = Convert.ToInt32((Math.Abs((float)gamepad.LeftThumbY) < deadband) ? 0 : (float)gamepad.LeftThumbY / short.MaxValue * 100); - rightThumb.X = Convert.ToInt32((Math.Abs((float)gamepad.RightThumbX) < deadband) ? 0 : (float)gamepad.RightThumbX / short.MaxValue * 100); - rightThumb.Y = Convert.ToInt32((Math.Abs((float)gamepad.RightThumbY) < deadband) ? 0 : (float)gamepad.RightThumbY / short.MaxValue * 100); - - // Triggers - leftTrigger = gamepad.LeftTrigger; - rightTrigger = gamepad.RightTrigger; - - // A, B, X, Y - buttons.A = (btns & GamepadButtonFlags.A) != 0; - buttons.B = (btns & GamepadButtonFlags.B) != 0; - buttons.X = (btns & GamepadButtonFlags.X) != 0; - buttons.Y = (btns & GamepadButtonFlags.Y) != 0; - - // Left and Right bumpers - buttons.LB = (btns & GamepadButtonFlags.LeftShoulder) != 0; - buttons.RB = (btns & GamepadButtonFlags.RightShoulder) != 0; - - // Clicking left and right thumbsticks - buttons.LeftStick = (btns & GamepadButtonFlags.LeftThumb) != 0; - buttons.RightStick = (btns & GamepadButtonFlags.RightThumb) != 0; - - // Start & Back - buttons.Back = (btns & GamepadButtonFlags.Back) != 0; - buttons.Start = (btns & GamepadButtonFlags.Start) != 0; - - // D-Pad - buttons.DLeft = (btns & GamepadButtonFlags.DPadLeft) != 0; - buttons.DUp = (btns & GamepadButtonFlags.DPadUp) != 0; - buttons.DRight = (btns & GamepadButtonFlags.DPadRight) != 0; - buttons.DDown = (btns & GamepadButtonFlags.DPadDown) != 0; - - // Battery - batteryLevel = batteryInfo.BatteryLevel.ToString(); - batteryType = batteryInfo.BatteryType.ToString(); - - switch (batteryInfo.BatteryLevel) { - case BatteryLevel.Empty: - batteryColor = Color.DarkGray; - break; - case BatteryLevel.Low: - batteryColor = Color.Red; - break; - case BatteryLevel.Medium: - batteryColor = Color.Orange; - break; - case BatteryLevel.Full: - batteryColor = Color.Green; - break; - } - } - - // Sets the vibration strength - public void setVibration(int lv, int rv) { - if (!connected) { return; } - - vibration.LeftMotorSpeed = Convert.ToUInt16(lv * 655); - vibration.RightMotorSpeed = Convert.ToUInt16(rv * 655); - controller.SetVibration(vibration); - } - } -} diff --git a/robospot-camera-finder.csproj b/robospot-camera-finder.csproj index 373a798..9ff88ba 100644 --- a/robospot-camera-finder.csproj +++ b/robospot-camera-finder.csproj @@ -16,11 +16,9 @@ - -