Exemplo n.º 1
0
 /// <summary>
 /// Clear the selection of any <see cref="SerializablePanel"/>.
 /// </summary>
 void DeselectEverything()
 {
     if (selection != null)
     {
         selection.OnDeselect();
         selection = null;
     }
     roomSettings.Visible     = false;
     obstacleSettings.Visible = false;
     sensorSettings.Visible   = false;
     doorSettings.Visible     = false;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Open and fill the corresponding settings panel for a <see cref="SerializablePanel"/>.
        /// </summary>
        internal void SelectObject(SerializablePanel target)
        {
            DeselectEverything();
            selection = target;
            target.OnSelect();
            switch (target)
            {
            case Room room:
                ShowRoomPanel(room);
                break;

            case Obstacle obstacle:
                obstacleName.Text        = target.Name;
                obstacleSettings.Visible = true;
                break;

            case Sensor sensor:
                selection = target;
                ShowRoomPanel((Room)target.Parent);
                sensorName.Text        = sensor.Name;
                sensorAddress.Text     = sensor.Address;
                sensorSettings.Visible = true;
                break;

            case Door door:
                switch (door.DoorType)
                {
                case DoorTypes.Door: doorDoor.Checked = true; break;

                case DoorTypes.Entrance: doorEntrance.Checked = true; break;

                case DoorTypes.Window: doorWindow.Checked = true; break;

                default: break;
                }
                doorHorizontal.Checked = door.Orientation == Door.Orientations.Horizontal;
                doorVertical.Checked   = door.Orientation == Door.Orientations.Vertical;
                doorSize.Value         = door.Size;
                doorSettings.Visible   = true;
                bool hasSensor = door.AttachedSensor != null;
                doorSensorAttached.Checked = hasSensor;
                doorSensorAddress.Enabled  = hasSensor;
                doorSensorAddress.Text     = hasSensor ? door.AttachedSensor.Address : string.Empty;
                break;
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Check if two elements have an intersection.
 /// </summary>
 /// <param name="Container">First element</param>
 /// <param name="Content">Second element</param>
 /// <remarks>They intersect, if the second rectangle is not entirely left/right/up/down from the first</remarks>
 public static bool Intersect(SerializablePanel Container, SerializablePanel Content) =>
 !(Container.Left >= Content.Right || Container.Top >= Content.Bottom ||
   Container.Right <= Content.Left || Container.Bottom <= Content.Top);