/// <summary> /// Set color when activated. /// </summary> public override void OnActivate() { base.OnActivate(); lastActivation = DateTime.Now; LastLocation = (SerializablePanel)Parent; LastLocation.OnActivate(); if (activations.Count == 0 || activations[activations.Count - 1] != this) { activations.Add(this); if (activations.Count >= ActivationHistoryLength) { activations = activations.GetRange(activations.Count - ActivationHistoryLength, ActivationHistoryLength); } } }
/// <summary> /// A sensor in a room. /// </summary> /// <param name="parent">Containing element</param> public Sensor(SerializablePanel parent) : base(parent) { color = new ColorStack(BaseColor, SelectionColor, ActivationColor); // Marker label marker = new Label { AutoSize = false, ForeColor = Color.Gray, Dock = DockStyle.Fill, Size = new Size(SensorSize, SensorSize), Text = "O", TextAlign = ContentAlignment.MiddleCenter }; marker.Font = new Font(marker.Font.FontFamily, SensorSize / 2); Controls.Add(marker); // Set mouse behaviour (on the filling label, because that's on top) SetDraggable(marker); // Design Repaint(); Size = new Size(25, 25); BringToFront(); // Sensors are always above every other object sensors.Add(this); }