// // (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; namespace Revit.SDK.Samples.NewHostedSweep.CS { /// /// This is the main form. It is the entry to create a new hosted sweep or to modify /// a created hosted sweep. /// public partial class MainForm : System.Windows.Forms.Form { /// /// Encapsulates the data source for a form. /// BindingSource m_binding; /// /// Creation manager, which collects all the creators. /// private CreationMgr m_creationMgr; /// /// Default constructor /// public MainForm() { InitializeComponent(); } /// /// Customize constructor. /// /// public MainForm(CreationMgr mgr): this() { m_creationMgr = mgr; m_binding = new BindingSource(); } /// /// Show a form to fetch edges for hosted-sweep creation, and then create /// the hosted-sweep. /// /// /// private void buttonCreate_Click(object sender, EventArgs e) { HostedSweepCreator creator = comboBoxHostedSweepType.SelectedItem as HostedSweepCreator; CreationData creationData = new CreationData(creator); using (EdgeFetchForm createForm = new EdgeFetchForm(creationData)) { if (createForm.ShowDialog() == DialogResult.OK) { creator.Create(creationData); RefreshListBox(); } } } /// /// Show a form to modify the created hosted-sweep. /// /// /// private void buttonModify_Click(object sender, EventArgs e) { ModificationData modificationData = listBoxCreatedHostedSweeps.SelectedItem as ModificationData; using(HostedSweepModifyForm modifyForm = new HostedSweepModifyForm(modificationData)) { modifyForm.ShowDialog(); } } /// /// Refresh list box data source. /// private void RefreshListBox() { HostedSweepCreator creator = comboBoxHostedSweepType.SelectedItem as HostedSweepCreator; m_binding.DataSource = creator.CreatedHostedSweeps; listBoxCreatedHostedSweeps.DataSource = m_binding; listBoxCreatedHostedSweeps.DisplayMember = "Name"; m_binding.ResetBindings(false); } /// /// Initialize combobox data source. /// private void InitializeComboBox() { comboBoxHostedSweepType.DropDownStyle = ComboBoxStyle.DropDownList; comboBoxHostedSweepType.Items.Add(m_creationMgr.FasciaCreator); comboBoxHostedSweepType.Items.Add(m_creationMgr.GutterCreator); comboBoxHostedSweepType.Items.Add(m_creationMgr.SlabEdgeCreator); comboBoxHostedSweepType.SelectedIndex = 0; comboBoxHostedSweepType.DisplayMember = "Name"; } /// /// Initialize combo-box. /// /// /// private void MainForm_Load(object sender, EventArgs e) { InitializeComboBox(); } /// /// Close this form. /// /// /// private void buttonOK_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.OK; this.Close(); } /// /// Update "Modify" button status according to the list-box selection item. /// /// /// private void listBoxHostedSweeps_SelectedValueChanged(object sender, EventArgs e) { if (listBoxCreatedHostedSweeps.SelectedItem != null) buttonModify.Enabled = true; else buttonModify.Enabled = false; } /// /// Update the list-box data source according to the combobox selection. /// /// /// private void comboBoxHostedSweepType_SelectedIndexChanged(object sender, EventArgs e) { RefreshListBox(); } } }