/// <summary> /// Initializes a new instance of the DashboardForm class /// </summary> /// <param name="theEventsPort">The Events Port for passing events back to the service</param> /// <param name="state">The service state</param> public DashboardForm(DashboardFormEvents theEventsPort, RobotDashboardState state) { this.eventsPort = theEventsPort; this.InitializeComponent(); this.options = new GUIOptions(); this.options = state.Options; this.StartPosition = FormStartPosition.Manual; this.Location = new Point(this.options.WindowStartX, this.options.WindowStartY); // The dead zone can't be negative, but it can be zero this.options.DeadZoneX = Math.Abs(state.Options.DeadZoneX); this.options.DeadZoneY = Math.Abs(state.Options.DeadZoneY); // Just in case the scale factors have not been initialized if (state.Options.TranslateScaleFactor == 0) { this.options.TranslateScaleFactor = 1.0; } else { this.options.TranslateScaleFactor = state.Options.TranslateScaleFactor; } if (state.Options.RotateScaleFactor == 0) { this.options.RotateScaleFactor = 0.5; } else { this.options.RotateScaleFactor = state.Options.RotateScaleFactor; } }
/// <summary> /// Initialize the State with appropriate values /// </summary> private void InitializeState() { bool newState = false; if (this.state == null) { this.state = new RobotDashboardState { TiltAngle = 0 }; newState = true; } if (this.state.Options == null) { this.state.Options = new GUIOptions { DeadZoneX = 150, DeadZoneY = 150, WindowStartX = 10, WindowStartY = 10 }; // Window geometry parameters this.state.Options.DepthcamWindowStartX = this.state.Options.WindowStartX + 450; this.state.Options.DepthcamWindowStartY = this.state.Options.WindowStartY; this.state.Options.DepthcamWindowWidth = 360; this.state.Options.DepthcamWindowHeight = 300; this.state.Options.WebcamWindowStartX = this.state.Options.WindowStartX + 450; this.state.Options.WebcamWindowStartY = this.state.Options.WindowStartY + 310; this.state.Options.WebcamWindowWidth = 360; this.state.Options.WebcamWindowHeight = 300; this.state.Options.TranslateScaleFactor = 0.7; this.state.Options.RotateScaleFactor = 0.4; // Camera update interval in milliseconds // Note that this is only required for the // simulated webcam because it does not provide // updates when you subscribe this.state.Options.CameraInterval = 250; } if (this.state.Options.CameraInterval < 100) { this.state.Options.CameraInterval = 100; } if (newState) { SaveState(this.state); } }