Beispiel #1
0
        private void offsetTextBox_TextChanged(object sender, EventArgs e)
        {
            // Do NOTHING if the offset is being displayed during startup
            if (m_IsStatic)
            {
                return;
            }

            // If the offset field is empty, disable the left/right radio buttons.
            // Otherwise enable them so long as we have an offset distance.
            string str = offsetTextBox.Text.Trim();

            if (str.Length == 0)
            {
                leftRadioButton.Enabled = rightRadioButton.Enabled = false;
                m_Offset = null;
                m_Cmd.SetOffset(null);
            }
            else
            {
                // If the offset is NOT an offset point, parse the offset,
                // notify the command, and enable the left/right radios.
                if (m_Offset is OffsetPoint)
                {
                    return;
                }

                // Get the entered text and parse it.
                Distance dist = new Distance(str);
                if (!dist.IsDefined)
                {
                    return;
                }

                // If we previously had an offset distance, see whether
                // it is to the left or right. Then throw it away.
                bool isLeft = true;
                if (m_Offset != null)
                {
                    OffsetDistance offDist = (m_Offset as OffsetDistance);
                    Debug.Assert(offDist != null);
                    isLeft   = !offDist.IsRight;
                    m_Offset = null;
                }
                else
                {
                    rightRadioButton.Checked = false;
                    leftRadioButton.Checked  = true;
                }

                // Enable radio buttons.
                leftRadioButton.Enabled = rightRadioButton.Enabled = true;

                // Create a new offset distance and tell the command.
                m_Offset = new OffsetDistance(dist, isLeft);
                m_Cmd.SetOffset(m_Offset);
            }
        }
Beispiel #2
0
        private void GetOffsetForm_Shown(object sender, EventArgs e)
        {
            // If we already have an offset, display it.
            if (m_Offset != null)
            {
                // If it's an offset point, just display the point ID and disable the left/right
                // radio buttons. For an offset distance, display the distance and check
                // the appropriate radio button.

                if (m_Offset is OffsetPoint)
                {
                    OffsetPoint op = (m_Offset as OffsetPoint);
                    offsetTextBox.Text      = String.Format("+{0}", op.Point.FormattedKey);
                    leftRadioButton.Enabled = rightRadioButton.Enabled = false;
                }
                else if (m_Offset is OffsetDistance)
                {
                    OffsetDistance od   = (m_Offset as OffsetDistance);
                    Distance       dist = od.Offset;
                    offsetTextBox.Text = dist.Format();

                    if (od.IsRight)
                    {
                        leftRadioButton.Checked  = false;
                        rightRadioButton.Checked = true;
                    }
                    else
                    {
                        rightRadioButton.Checked = false;
                        leftRadioButton.Checked  = true;
                    }
                }
                else
                {
                    throw new ArgumentException("Unexpected type of offset");
                }
            }
            else
            {
                // Disable the left/right radios. They'll get enabled if
                // an offset distance is entered.
                leftRadioButton.Enabled = rightRadioButton.Enabled = false;
            }

            // OnChangeOffset is now free to null m_Offset as required.
            m_IsStatic = false;
        }
Beispiel #3
0
        void SetOffsetRight(bool isRight)
        {
            // The offset HAS to be an offset distance.
            OffsetDistance dist = (m_Offset as OffsetDistance);

            if (dist == null)
            {
                return;
            }

            // Record the offset side.
            if (isRight)
            {
                dist.SetRight();
            }
            else
            {
                dist.SetLeft();
            }

            // Tell the command.
            m_Cmd.SetOffset(dist);
        }