// // (C) Copyright 2003-2019 by Autodesk, Inc. // // Permission to use, copy, modify, and distribute this software in // object code form for any purpose and without fee is hereby granted, // provided that the above copyright notice appears in all copies and // that both that copyright notice and the limited warranty and // restricted rights notice below appear in all supporting // documentation. // // AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. // AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE // UNINTERRUPTED OR ERROR FREE. // // Use, duplication, or disclosure by the U.S. Government is subject to // restrictions set forth in FAR 52.227-19 (Commercial Computer // Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) // (Rights in Technical Data and Computer Software), as applicable. // using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Autodesk.Revit.DB; using Autodesk.Revit.DB.Mechanical; namespace Revit.SDK.Samples.AddSpaceAndZone.CS { /// /// The ZoneEditorForm Class the user interface to edit a Zone element. /// public partial class ZoneEditorForm : System.Windows.Forms.Form { /// /// The default constructor of ZoneEditorForm class. /// private ZoneEditorForm() { InitializeComponent(); } /// /// The constructor of ZoneEditorForm class. /// /// /// public ZoneEditorForm(DataManager dataManager, ZoneNode zoneNode) { m_dataManager = dataManager; m_zoneNode = zoneNode; m_zone = m_zoneNode.Zone; InitializeComponent(); } /// /// When the addSpace Button is clicked, the selected spaces will be added to the /// current Zone element. /// /// /// private void addSpaceButton_Click(object sender, EventArgs e) { SpaceSet set = new SpaceSet(); foreach (SpaceItem item in this.availableSpacesListView.SelectedItems) { set.Insert(item.Space); } m_zone.AddSpaces(set); UpdateSpaceList(); } /// /// When the removeSpace Button is clicked, the selected spaces will be removed from the /// current Zone element. /// /// /// private void removeSpaceButton_Click(object sender, EventArgs e) { SpaceSet set = new SpaceSet(); foreach (SpaceItem item in this.currentSpacesListView.SelectedItems) { set.Insert(item.Space); } m_zone.RemoveSpaces(set); UpdateSpaceList(); } /// /// When the ZoneEditorForm is loaded, update the AvailableSpacesListView and CurrentSpacesListView /// /// /// private void ZoneEditorForm_Load(object sender, EventArgs e) { this.Text = "Edit Zone : " + m_zone.Name; UpdateSpaceList(); } /// /// Update the AvailableSpacesListView and CurrentSpacesListView /// private void UpdateSpaceList() { this.availableSpacesListView.Items.Clear(); this.currentSpacesListView.Items.Clear(); // AvailableSpacesListView foreach (Space space in m_dataManager.GetSpaces()) { if (m_zone.Spaces.Contains(space) == false) { this.availableSpacesListView.Items.Add(new SpaceItem(space)); } } // CurrentSpacesListView foreach (Space space in m_zone.Spaces) { this.currentSpacesListView.Items.Add(new SpaceItem(space)); } this.availableSpacesListView.Update(); this.currentSpacesListView.Update(); } /// /// When OK button is clicked, close the ZoneEditorForm. /// /// /// private void okButton_Click(object sender, EventArgs e) { this.Close(); } } }