Пример #1
0
        /// <summary>
        /// Event when OK button is pressed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void buttonOK_Click(object sender, RoutedEventArgs args)
        {
            // Saved changes to both Address Tab items and File Header Tab items if they have changed

            if (m_newAddressItem.isUnchanged(m_savedAddressItem) == false)
            {
                m_newAddress.UpdateAddress(IFCCommandOverrideApplication.TheDocument, m_newAddressItem);
            }

            if (m_newFileHeaderItem.isUnchanged(m_savedFileHeaderItem) == false)
            {
                m_newFileHeader.UpdateFileHeader(IFCCommandOverrideApplication.TheDocument, m_newFileHeaderItem);
            }

            if (m_newAddressItem.UpdateProjectInformation == true)
            {
                // Format IFC address and update it into Project Information: Project Address
                String address = null;
                String geographicMapLocation = null;
                bool   addNewLine            = false;

                if (String.IsNullOrEmpty(m_newAddressItem.AddressLine1) == false)
                {
                    address += string.Format("{0}\r\n", m_newAddressItem.AddressLine1);
                }
                if (String.IsNullOrEmpty(m_newAddressItem.AddressLine2) == false)
                {
                    address += string.Format("{0}\r\n", m_newAddressItem.AddressLine2);
                }
                if (String.IsNullOrEmpty(m_newAddressItem.POBox) == false)
                {
                    address += string.Format("{0}\r\n", m_newAddressItem.POBox);
                }
                if (String.IsNullOrEmpty(m_newAddressItem.TownOrCity) == false)
                {
                    address   += string.Format("{0}", m_newAddressItem.TownOrCity);
                    addNewLine = true;
                }
                if (String.IsNullOrEmpty(m_newAddressItem.RegionOrState) == false)
                {
                    address   += string.Format(", {0}", m_newAddressItem.RegionOrState);
                    addNewLine = true;
                }
                if (String.IsNullOrEmpty(m_newAddressItem.PostalCode) == false)
                {
                    address   += string.Format(" {0}", m_newAddressItem.PostalCode);
                    addNewLine = true;
                }
                if (addNewLine == true)
                {
                    address   += string.Format("\r\n");
                    addNewLine = false;
                }

                if (String.IsNullOrEmpty(m_newAddressItem.Country) == false)
                {
                    address += string.Format("{0}\r\n", m_newAddressItem.Country);
                }

                if (String.IsNullOrEmpty(m_newAddressItem.InternalLocation) == false)
                {
                    address += string.Format("\r\n{0}: {1}\r\n",
                                             Properties.Resources.InternalAddress, m_newAddressItem.InternalLocation);
                }

                if (String.IsNullOrEmpty(m_newAddressItem.TownOrCity) == false)
                {
                    geographicMapLocation = m_newAddressItem.TownOrCity;
                }

                if (String.IsNullOrEmpty(m_newAddressItem.RegionOrState) == false)
                {
                    if (String.IsNullOrEmpty(geographicMapLocation) == false)
                    {
                        geographicMapLocation = geographicMapLocation + ", " + m_newAddressItem.RegionOrState;
                    }
                    else
                    {
                        geographicMapLocation = m_newAddressItem.RegionOrState;
                    }
                }

                if (String.IsNullOrEmpty(m_newAddressItem.Country) == false)
                {
                    if (String.IsNullOrEmpty(geographicMapLocation) == false)
                    {
                        geographicMapLocation = geographicMapLocation + ", " + m_newAddressItem.Country;
                    }
                    else
                    {
                        geographicMapLocation = m_newAddressItem.Country;
                    }
                }
                ;

                Transaction transaction = new Transaction(IFCCommandOverrideApplication.TheDocument, Properties.Resources.UpdateProjectAddress);
                transaction.Start();

                ProjectInfo projectInfo = IFCCommandOverrideApplication.TheDocument.ProjectInformation;
                projectInfo.Address = address;    // set project address information using the IFC Address Information when requested

                if (String.IsNullOrEmpty(geographicMapLocation) == false)
                {
                    IFCCommandOverrideApplication.TheDocument.ActiveProjectLocation.SiteLocation.PlaceName = geographicMapLocation;    // Update also Revit Site location on the Map using City, State and Country when they are not null
                }
                transaction.Commit();
            }

            // Update Classification if it has changed or the mandatory fields are filled. If mandatory fields are not filled we will ignore the classification.
            if (!m_newClassification.IsUnchanged(m_savedClassification))
            {
                if (m_newClassification.AreMandatoryFieldsFilled())
                {
                    IFCClassificationMgr.UpdateClassification(IFCCommandOverrideApplication.TheDocument, m_newClassification);
                }
                else if (!m_newClassification.IsClassificationEmpty())
                {
                    m_newClassification.ClassificationTabMsg = Properties.Resources.ManditoryFieldsNotEmpty;
                    return;
                }
            }

            m_newClassification.ClassificationTabMsg = null;
            Close();
        }
        /// <summary>
        /// Event when OK button is pressed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void buttonOK_Click(object sender, RoutedEventArgs args)
        {
            if (Checkbox_AssignToBuilding.IsChecked.HasValue && Checkbox_AssignToBuilding.IsChecked.Value == true)
            {
                m_newAddressItem.AssignAddressToBuilding = true;
            }
            else
            {
                m_newAddressItem.AssignAddressToBuilding = false;
            }

            if (Checkbox_AssignToSite.IsChecked.HasValue && Checkbox_AssignToSite.IsChecked.Value == true)
            {
                m_newAddressItem.AssignAddressToSite = true;
            }
            else
            {
                m_newAddressItem.AssignAddressToSite = false;
            }

            // Saved changes to both Address Tab items and File Header Tab items if they have changed

            if (m_newAddressItem.isUnchanged(m_savedAddressItem) == false)
            {
                m_newAddress.UpdateAddress(IFCCommandOverrideApplication.TheDocument, m_newAddressItem);
            }

            if (m_newAddressItem.UpdateProjectInformation == true)
            {
                // Format IFC address and update it into Project Information: Project Address
                String address = null;
                String geographicMapLocation = null;
                bool   addNewLine            = false;

                if (String.IsNullOrEmpty(m_newAddressItem.AddressLine1) == false)
                {
                    address += string.Format("{0}\r\n", m_newAddressItem.AddressLine1);
                }
                if (String.IsNullOrEmpty(m_newAddressItem.AddressLine2) == false)
                {
                    address += string.Format("{0}\r\n", m_newAddressItem.AddressLine2);
                }
                if (String.IsNullOrEmpty(m_newAddressItem.POBox) == false)
                {
                    address += string.Format("{0}\r\n", m_newAddressItem.POBox);
                }
                if (String.IsNullOrEmpty(m_newAddressItem.TownOrCity) == false)
                {
                    address   += string.Format("{0}", m_newAddressItem.TownOrCity);
                    addNewLine = true;
                }
                if (String.IsNullOrEmpty(m_newAddressItem.RegionOrState) == false)
                {
                    address   += string.Format(", {0}", m_newAddressItem.RegionOrState);
                    addNewLine = true;
                }
                if (String.IsNullOrEmpty(m_newAddressItem.PostalCode) == false)
                {
                    address   += string.Format(" {0}", m_newAddressItem.PostalCode);
                    addNewLine = true;
                }
                if (addNewLine == true)
                {
                    address   += string.Format("\r\n");
                    addNewLine = false;
                }

                if (String.IsNullOrEmpty(m_newAddressItem.Country) == false)
                {
                    address += string.Format("{0}\r\n", m_newAddressItem.Country);
                }

                if (String.IsNullOrEmpty(m_newAddressItem.InternalLocation) == false)
                {
                    address += string.Format("\r\n{0}: {1}\r\n",
                                             Properties.Resources.InternalAddress, m_newAddressItem.InternalLocation);
                }

                if (String.IsNullOrEmpty(m_newAddressItem.TownOrCity) == false)
                {
                    geographicMapLocation = m_newAddressItem.TownOrCity;
                }

                if (String.IsNullOrEmpty(m_newAddressItem.RegionOrState) == false)
                {
                    if (String.IsNullOrEmpty(geographicMapLocation) == false)
                    {
                        geographicMapLocation = geographicMapLocation + ", " + m_newAddressItem.RegionOrState;
                    }
                    else
                    {
                        geographicMapLocation = m_newAddressItem.RegionOrState;
                    }
                }

                if (String.IsNullOrEmpty(m_newAddressItem.Country) == false)
                {
                    if (String.IsNullOrEmpty(geographicMapLocation) == false)
                    {
                        geographicMapLocation = geographicMapLocation + ", " + m_newAddressItem.Country;
                    }
                    else
                    {
                        geographicMapLocation = m_newAddressItem.Country;
                    }
                }
                ;

                Transaction transaction = new Transaction(IFCCommandOverrideApplication.TheDocument, Properties.Resources.UpdateProjectAddress);
                transaction.Start();

                ProjectInfo projectInfo = IFCCommandOverrideApplication.TheDocument.ProjectInformation;
                projectInfo.Address = address; // set project address information using the IFC Address Information when requested

                if (String.IsNullOrEmpty(geographicMapLocation) == false)
                {
                    IFCCommandOverrideApplication.TheDocument.ActiveProjectLocation.GetSiteLocation().PlaceName = geographicMapLocation; // Update also Revit Site location on the Map using City, State and Country when they are not null
                }
                transaction.Commit();
            }

            Close();
        }