示例#1
0
        /// <summary>
        /// add curtain grids to the checked faces
        /// </summary>
        /// <param name="sender">
        /// object who sent this event
        /// </param>
        /// <param name="e">
        /// event args
        /// </param>
        private void addCGButton_Click(object sender, EventArgs e)
        {
            // step 1: get the curtain system
            List <CurtainSystem.SystemInfo> csInfos = m_mydocument.SystemData.CurtainSystemInfos;

            // no curtain system available, ask sample user to create some curtain systems first
            if (null == csInfos || 0 == csInfos.Count)
            {
                string hint = Properties.Resources.HINT_CreateCSFirst;
                m_mydocument.Message = new KeyValuePair <string, bool>(hint, true);
                return;
            }
            CurtainSystem.SystemInfo csInfo = csInfos[csListBox.SelectedIndex];
            // if the curtain system is created by face array, it's forbidden to make other operations on it
            if (true == csInfo.ByFaceArray)
            {
                return;
            }
            // step 2: find out the faces to be covered
            List <int> faceIndices = new List <int>();

            for (int i = 0; i < facesCheckedListBox.Items.Count; i++)
            {
                bool itemChecked = facesCheckedListBox.GetItemChecked(i);
                if (true == itemChecked)
                {
                    CurtainSystem.UncoverFaceInfo info = facesCheckedListBox.Items[i] as CurtainSystem.UncoverFaceInfo;
                    faceIndices.Add(info.Index);
                }
            }

            // no uncovered faces selected, warn the sample user
            if (null == faceIndices ||
                0 == faceIndices.Count)
            {
                string hint = Properties.Resources.HINT_SelectFaceFirst;
                m_mydocument.Message = new KeyValuePair <string, bool>(hint, true);
                return;
            }

            // step 3: cover the selected faces with curtain grids
            csInfo.AddCurtainGrids(faceIndices);
            // step 4: update the UI list boxes
            csListBox_SelectedIndexChanged(null, null);
        }
示例#2
0
        /// <summary>
        /// the selected curtain system changed, update the "Curtain grid" and
        /// "Uncovered faces" list boxes of the selected curtain system
        /// </summary>
        /// <param name="sender">
        /// object who sent this event
        /// </param>
        /// <param name="e">
        /// event args
        /// </param>
        private void csListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            List <CurtainSystem.SystemInfo> csInfos = m_mydocument.SystemData.CurtainSystemInfos;

            // data verification
            if (null == csInfos ||
                0 == csInfos.Count)
            {
                return;
            }

            //
            // step 1: activate the selected one
            //
            CurtainSystem.SystemInfo csInfo = csInfos[csListBox.SelectedIndex];
            // update the curtain grid list box
            cgCheckedListBox.Items.Clear();
            foreach (int index in csInfo.GridFacesIndices)
            {
                CurtainSystem.GridFaceInfo gridFaceInfo = new CurtainSystem.GridFaceInfo(index);
                cgCheckedListBox.Items.Add(gridFaceInfo);
            }
            // update the uncovered face list box
            facesCheckedListBox.Items.Clear();
            foreach (int index in csInfo.UncoverFacesIndices)
            {
                CurtainSystem.UncoverFaceInfo uncoverFaceInfo = new CurtainSystem.UncoverFaceInfo(index);
                facesCheckedListBox.Items.Add(uncoverFaceInfo);
            }
            //
            // step 2: enable/disable some buttons and refresh the status hints
            //
            // the selected curtain system is created by face array
            // it's not allowed to modify its curtain grids data
            if (true == csInfo.ByFaceArray)
            {
                // disable the buttons
                this.addCGButton.Enabled         = false;
                this.removeCGButton.Enabled      = false;
                this.facesCheckedListBox.Enabled = false;
                this.cgCheckedListBox.Enabled    = false;
                // update the status hints
                string hint = Properties.Resources.HINT_CSIsByFaceArray;
                m_mydocument.Message = new KeyValuePair <string, bool>(hint, false);
            }
            // the selected curtain system is created by references of the faces
            // it's allowed to modify its curtain grids data
            else
            {
                // enable the buttons
                if (null == facesCheckedListBox.Items ||
                    0 == facesCheckedListBox.Items.Count)
                {
                    this.addCGButton.Enabled = false;
                }
                else
                {
                    this.addCGButton.Enabled = true;
                }
                // at least one curtain grid must be kept
                if (null == cgCheckedListBox.Items ||
                    2 > cgCheckedListBox.Items.Count)
                {
                    this.removeCGButton.Enabled = false;
                }
                else
                {
                    this.removeCGButton.Enabled = true;
                }
                this.facesCheckedListBox.Enabled = true;
                this.cgCheckedListBox.Enabled    = true;
                // update the status hints
                string hint = "";
                m_mydocument.Message = new KeyValuePair <string, bool>(hint, false);
            }
        }
示例#3
0
文件: CurtainForm.cs 项目: AMEE/revit
        /// <summary>
        /// the selected curtain system changed, update the "Curtain grid" and 
        /// "Uncovered faces" list boxes of the selected curtain system
        /// </summary>
        /// <param name="sender">
        /// object who sent this event 
        /// </param>
        /// <param name="e"> 
        /// event args 
        /// </param>
        private void csListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            List<CurtainSystem.SystemInfo> csInfos = m_mydocument.SystemData.CurtainSystemInfos;

             // data verification
             if (null == csInfos ||
             0 == csInfos.Count)
             {
            return;
             }

             //
             // step 1: activate the selected one
             //
             CurtainSystem.SystemInfo csInfo = csInfos[csListBox.SelectedIndex];
             // update the curtain grid list box
             cgCheckedListBox.Items.Clear();
             foreach (int index in csInfo.GridFacesIndices)
             {
            CurtainSystem.GridFaceInfo gridFaceInfo = new CurtainSystem.GridFaceInfo(index);
            cgCheckedListBox.Items.Add(gridFaceInfo);
             }
             // update the uncovered face list box
             facesCheckedListBox.Items.Clear();
             foreach (int index in csInfo.UncoverFacesIndices)
             {
            CurtainSystem.UncoverFaceInfo uncoverFaceInfo = new CurtainSystem.UncoverFaceInfo(index);
            facesCheckedListBox.Items.Add(uncoverFaceInfo);
             }
             //
             // step 2: enable/disable some buttons and refresh the status hints
             //
             // the selected curtain system is created by face array
             // it's not allowed to modify its curtain grids data
             if (true == csInfo.ByFaceArray)
             {
            // disable the buttons
            this.addCGButton.Enabled = false;
            this.removeCGButton.Enabled = false;
            this.facesCheckedListBox.Enabled = false;
            this.cgCheckedListBox.Enabled = false;
            // update the status hints
            string hint = Properties.Resources.HINT_CSIsByFaceArray;
            m_mydocument.Message = new KeyValuePair<string, bool>(hint, false);
             }
             // the selected curtain system is created by references of the faces
             // it's allowed to modify its curtain grids data
             else
             {
            // enable the buttons
            if (null == facesCheckedListBox.Items ||
                0 == facesCheckedListBox.Items.Count)
            {
               this.addCGButton.Enabled = false;
            }
            else
            {
               this.addCGButton.Enabled = true;
            }
            // at least one curtain grid must be kept
            if (null == cgCheckedListBox.Items ||
                2 > cgCheckedListBox.Items.Count)
            {
               this.removeCGButton.Enabled = false;
            }
            else
            {
               this.removeCGButton.Enabled = true;
            }
            this.facesCheckedListBox.Enabled = true;
            this.cgCheckedListBox.Enabled = true;
            // update the status hints
            string hint = "";
            m_mydocument.Message = new KeyValuePair<string, bool>(hint, false);
             }
        }