/// <summary> /// Called when the user selects a task from the task menu. /// </summary> /// <param name="sender">Not used</param> /// <param name="args">Not used</param> private void taskMenuItem_Click(object sender, EventArgs args) { HulkTask task; logger.Debug("Enter: taskMenuItem_Click(object, EventArgs)"); task = (HulkTask)Activator.CreateInstance((Type)((ToolStripMenuItem)sender).Tag); AppMain.CurrentTask = task; Controls.Remove(taskPanel); taskPanel = new NamedPanel(task.TaskPanel, "Task", ColorScheme.Instance.TaskPanelMarker) { Margin = new Padding(0, 0, 3, 3) }; Controls.Add(taskPanel); GraphPanel gp = graphPanel.ChildPanel as GraphPanel; task.AxesCentersChanged += new HulkTask.AxesCentersChangedHandler(gp.axisCenters_Changed); }
/// <summary> /// Constructs the form GUI. /// </summary> private void InitializeGUI() { ControlPanel childControlPanel; AudioPanel childAudioPanel; GraphPanel childGraphPanel; LoggingPanel childLogPanel; StatusPanel childStatusPanel; logger.Debug("Enter: InitializeGUI()"); SuspendLayout(); WindowState = FormWindowState.Maximized; CheckForIllegalCrossThreadCalls = true; DoubleBuffered = true; Icon = new Icon(AppMain.BaseDirectory + "\\hulk.ico"); Text = "HULKamania [v " + ConfigurationManager.AppSettings["Version"] + "]"; BackColor = ColorScheme.Instance.FormBackground; FormBorderStyle = FormBorderStyle.FixedSingle; #region Menu Strip exitMenuItem = new ToolStripMenuItem("Exit"); exitMenuItem.Click += exitMenuItem_Click; fileMenu = new ToolStripMenuItem("File"); fileMenu.Tag = "PARENT"; fileMenu.DropDownItems.Add(exitMenuItem); taskMenuItems = new List <ToolStripMenuItem>(); foreach (Type task in AppMain.AvailableTasks) { taskMenuItems.Add(new ToolStripMenuItem(task.Name)); taskMenuItems[taskMenuItems.Count - 1].Tag = task; taskMenuItems[taskMenuItems.Count - 1].Click += taskMenuItem_Click; } tasksMenu = new ToolStripMenuItem("Tasks"); tasksMenu.Tag = "PARENT"; foreach (ToolStripMenuItem item in taskMenuItems) { tasksMenu.DropDownItems.Add(item); } startServerMenuItem = new ToolStripMenuItem("Start network server"); startServerMenuItem.Click += new EventHandler(startServerMenuItem_Click); startServerMenuItem.Enabled = !AppMain.ServerHandler.isServerStarted; stopServerMenuItem = new ToolStripMenuItem("Stop network server"); stopServerMenuItem.Click += new EventHandler(stopServerMenuItem_Click); stopServerMenuItem.Enabled = AppMain.ServerHandler.isServerStarted; sendProtocolMenuItem = new ToolStripMenuItem("Send protocol"); sendProtocolMenuItem.Click += new EventHandler(sendProtocolMenuItemMenuItem_Click); listNetworkConnectionsMenuItem = new ToolStripMenuItem("List network connections"); listNetworkConnectionsMenuItem.Click += new EventHandler(listNetworkConnectionsMenuItem_Click); resetOculusViewDirectionMenuItem = new ToolStripMenuItem("(Oculus Rift) Reset view direction"); resetOculusViewDirectionMenuItem.Click += resetOculusViewDirectionMenuItem_Click; resetTrackerOriginMenuItem = new ToolStripMenuItem("(VRPN Tracker) Reset tracker origin"); resetTrackerOriginMenuItem.Click += resetTrackerOriginMenuItem_Click; sendReconnectCommandToNetworkClientsMenuItem = new ToolStripMenuItem("Reconnect client(s) to server ..."); sendReconnectCommandToNetworkClientsMenuItem.Click += new EventHandler(sendReconnectCommandToNetworkClientsMenuItem_Click); scenesMenuItem = new ToolStripMenuItem("Scenes"); startAlignmentSceneMenuItem = new ToolStripMenuItem("Start alignment scene"); startAlignmentSceneMenuItem.Click += new EventHandler(startAlignmentSceneMenuItem_Click); stopAlignmentSceneMenuItem = new ToolStripMenuItem("Stop alignment scene"); stopAlignmentSceneMenuItem.Click += new EventHandler(stopAlignmentSceneMenuItem_Click); _updateScenesMenuItem(); networkMenu = new ToolStripMenuItem("Network"); networkMenu.Tag = "PARENT"; networkMenu.DropDownItems.Add(startServerMenuItem); networkMenu.DropDownItems.Add(stopServerMenuItem); networkMenu.DropDownItems.Add(listNetworkConnectionsMenuItem); networkMenu.DropDownItems.Add(new ToolStripSeparator()); networkMenu.DropDownItems.Add(sendProtocolMenuItem); networkMenu.DropDownItems.Add(new ToolStripSeparator()); networkMenu.DropDownItems.Add(resetTrackerOriginMenuItem); networkMenu.DropDownItems.Add(resetOculusViewDirectionMenuItem); networkMenu.DropDownItems.Add(sendReconnectCommandToNetworkClientsMenuItem); networkMenu.DropDownItems.Add(new ToolStripSeparator()); networkMenu.DropDownItems.Add(scenesMenuItem); menuStrip = new MenuStrip { Renderer = new MenuRenderer() }; menuStrip.Items.Add(fileMenu); menuStrip.Items.Add(tasksMenu); menuStrip.Items.Add(networkMenu); #endregion #region Status Bar statusLabel = new ToolStripStatusLabel { TextAlign = ContentAlignment.MiddleLeft, Spring = true }; statusTaskSeparator = new ToolStripSeparator(); taskLabel = new ToolStripStatusLabel { TextAlign = ContentAlignment.MiddleLeft, Spring = true }; taskJoystickSeparator = new ToolStripSeparator(); joystickLabel = new ToolStripStatusLabel { TextAlign = ContentAlignment.MiddleRight, Spring = false, Width = 150 }; joystickNetworkSeparator = new ToolStripSeparator(); networkLabel = new ToolStripStatusLabel { TextAlign = ContentAlignment.MiddleRight, Spring = false, Width = 150 }; networkPcSeparator = new ToolStripSeparator(); pcLabel = new ToolStripStatusLabel { TextAlign = ContentAlignment.MiddleRight, Spring = false, Width = 150 }; pcLightsSeparator = new ToolStripSeparator(); lightsLabel = new ToolStripStatusLabel { TextAlign = ContentAlignment.MiddleRight, Spring = false, Width = 150 }; lightsPlcSeparator = new ToolStripSeparator(); plcLabel = new ToolStripStatusLabel { TextAlign = ContentAlignment.MiddleRight, Spring = false, Width = 150 }; plcUpdateSeparator = new ToolStripSeparator(); updateLabel = new ToolStripStatusLabel { TextAlign = ContentAlignment.MiddleLeft, Spring = false, Width = 110 }; statusBar = new StatusStrip { BackColor = ColorScheme.Instance.StatusBarBackground, ForeColor = ColorScheme.Instance.StatusBarForeground }; statusBar.Items.Add(statusLabel); statusBar.Items.Add(statusTaskSeparator); statusBar.Items.Add(taskLabel); statusBar.Items.Add(taskJoystickSeparator); statusBar.Items.Add(joystickLabel); statusBar.Items.Add(joystickNetworkSeparator); statusBar.Items.Add(networkLabel); statusBar.Items.Add(networkPcSeparator); statusBar.Items.Add(pcLabel); statusBar.Items.Add(pcLightsSeparator); statusBar.Items.Add(lightsLabel); statusBar.Items.Add(lightsPlcSeparator); statusBar.Items.Add(plcLabel); statusBar.Items.Add(plcUpdateSeparator); statusBar.Items.Add(updateLabel); #endregion #region Panels childControlPanel = new ControlPanel(); controlPanel = new NamedPanel(childControlPanel, "Control", ColorScheme.Instance.ControlPanelMarker) { Margin = new Padding(3, 3, 3, 0) }; childAudioPanel = new AudioPanel(); audioPanel = new NamedPanel(childAudioPanel, "Audio", ColorScheme.Instance.AudioPanelMarker) { Margin = new Padding(3, 3, 3, 0) }; childGraphPanel = new GraphPanel(); graphPanel = new NamedPanel(childGraphPanel, "Graphs", ColorScheme.Instance.GraphsPanelMarker) { Margin = new Padding(3, 0, 0, 3) }; childLogPanel = new LoggingPanel(); loggingPanel = new NamedPanel(childLogPanel, "Event Log", ColorScheme.Instance.EventLogPanelMarker) { Margin = new Padding(3, 3, 0, 0) }; childStatusPanel = new StatusPanel(); statusPanel = new NamedPanel(childStatusPanel, "Status", ColorScheme.Instance.StatusPanelMarker) { Margin = new Padding(0, 3, 3, 0) }; taskPanel = new NamedPanel(new HulkTaskPanel(), "Task", ColorScheme.Instance.TaskPanelMarker) { Margin = new Padding(0, 0, 3, 3) }; #endregion Controls.Add(audioPanel); Controls.Add(controlPanel); Controls.Add(graphPanel); Controls.Add(loggingPanel); Controls.Add(menuStrip); Controls.Add(statusBar); Controls.Add(statusPanel); Controls.Add(taskPanel); Closing += MainForm_Closing; Layout += MainForm_Layout; Load += MainForm_Load; ResumeLayout(); layoutComplete = true; }