示例#1
0
        internal GetOffsetForm(CommandUI cmd, Offset offset)
        {
            InitializeComponent();

            m_Cmd = cmd;
            m_Offset = null;

            if (offset!=null)
            {
                if (offset is OffsetDistance)
                    m_Offset = new OffsetDistance(offset as OffsetDistance);
                else if (offset is OffsetPoint)
                    m_Offset = new OffsetPoint(offset as OffsetPoint);
            }

            // Don't let OnChangeOffset delete any offset until OnInitDialog has finished.
            m_IsStatic = true;
        }
示例#2
0
 internal override void SetOffset(Offset offset)
 {
     throw new Exception("The method or operation is not implemented.");
 }
示例#3
0
        bool InitOp(RadialOperation pop)
        {
            if (pop==null)
                return false;

            // Get the point the sideshot was observed from (unless
            // it is already defined).
            if (m_From==null)
                m_From = pop.From;

            // Was a backsight specified?
            Direction dir = pop.Direction;
            if (dir is AngleDirection)
            {
                AngleDirection angle = (AngleDirection)dir;
                m_Backsight = angle.Backsight;
                m_Radians = angle.ObservationInRadians;
                if (m_Radians < 0.0)
                {
                    m_Radians = Math.Abs(m_Radians);
                    m_IsClockwise = false;
                }
                else
                    m_IsClockwise = true;

                // Is it a deflection?
                m_IsDeflection = (dir is DeflectionDirection);
            }

            // Was direction specified using 2 points (not possible
            // if we've already picked up a backsight).
            if (m_Backsight==null)
            {
                ParallelDirection par = (dir as ParallelDirection);
                if (par!=null)
                {
                    m_Par1 = par.Start;
                    m_Par2 = par.End;
                }
            }
            else
            {
                // Does the backsight point correspond to the centre of a
                // circle that passes through the from-point?

                double radius = Geom.Distance(m_Backsight, m_From);
                if (m_Backsight.GetCircle(radius)!=null)
                    m_WantCentre = true;
            }

            // If we don't have a backsight or a parallel point, it must be a bearing.
            if (!(m_Backsight!=null || m_Par1!=null))
                m_Radians = dir.Bearing.Radians;

            // Did the direction have an offset? If so, make a transient
            // copy (specifying m_Length since it's transient).
            Offset offset = dir.Offset;
            if (offset!=null)
                m_Offset = offset;
                //m_Offset = offset.MakeNewCopy(m_Length);

            // The length was either entered explicitly, or via an offset point.
            Observation length = pop.Length;
            Distance dist = (length as Distance);

            if (dist!=null)
            {
                m_Length = new Distance(dist);
            }
            else
            {
                // It SHOULD be an offset point.
                OffsetPoint offsetPoint = (OffsetPoint)length;
                if (offsetPoint!=null)
                    m_LengthOffset = new OffsetPoint(offsetPoint);
            }

            // Remember whether a line was added.
            if (pop.Line!=null)
                m_WantLine = true;

            return true;
        }
示例#4
0
        /// <summary>
        /// Accepts a new direction offset.
        /// </summary>
        /// <param name="offset">The new offset (if any).</param>
        internal void SetOffset(Offset offset)
        {
            // If we previously had an offset point, make sure it's
            // drawn in it's normal colour.
            if (m_Offset!=null)
            {
                SetNormalColour(m_Offset.Point);
                m_Offset = null;
            }

            // If it's an offset point, draw the point in green.
            m_Offset = offset;
            if (offset!=null && offset.Point!=null)
                DrawPoints();

            // See if that changes anything.
            OnChange();
        }
示例#5
0
 private void Zero()
 {
     m_Cmd = null;
     m_Recall = null;
     m_From = null;
     m_Backsight = null;
     m_Par1 = null;
     m_Par2 = null;
     m_Radians = 0.0;
     m_IsClockwise = true;
     m_IsDeflection = false;
     m_Length = new Distance();
     m_LengthOffset = null;
     m_DialOff = null;
     m_Offset = null;
     m_Dir = null;
     m_To = null;
     m_Circles = new List<Circle>();
     m_Focus = null;
     m_WantLine = false;
     m_WantCentre = false;
     m_IsStatic = false;
     m_PointId = null;
 }
示例#6
0
 /// <summary>
 /// Accepts a new offset
 /// </summary>
 /// <param name="offset"></param>
 internal override void SetOffset(Offset offset)
 {
     if (m_Cmd != null)
         m_Cmd.SetOffset(offset);
 }
示例#7
0
 /// <summary>
 /// Sets any offset that applies to this command. This is a placeholder
 ///	only. Commands that accept an offset must implement their own version (if
 ///	they don't, this version will throw an exception, to indicate that the
 ///	function is missing).
 /// </summary>
 /// <param name="offset">The applicable offset (may be null)</param>
 internal virtual void SetOffset(Offset offset)
 {
     throw new NotImplementedException("CommandUI.SetOffset needs to be implemented by "+GetType().Name);
 }
示例#8
0
        internal void OnSelectPoint(PointFeature point)
        {
            // Return if point is not defined.
            if (point==null)
                return;

            // Get rid of any existing offset.
            m_Offset = null;

            // Create an offset point object.
            m_Offset = new OffsetPoint(point);

            // Display the key of the offset point.
            offsetTextBox.Text = String.Format("+{0}", point.FormattedKey);

            // Disable the left-right radio buttons.
            leftRadioButton.Enabled = rightRadioButton.Enabled = false;

            // Tell the command.
            m_Cmd.SetOffset(m_Offset);
        }
示例#9
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);
            }
        }
示例#10
0
 /// <summary>
 /// Reads data that was previously written using <see cref="WriteData"/>
 /// </summary>
 /// <param name="editDeserializer">The mechanism for reading back content.</param>
 /// <param name="offset">The offset.</param>
 static void ReadData(EditDeserializer editDeserializer, out Offset offset)
 {
     offset = editDeserializer.ReadPersistentOrNull<Offset>(DataField.Offset);
 }
示例#11
0
 protected Direction()
 {
     m_Offset = null;
 }
示例#12
0
 /// <summary>
 /// Accepts a new offset.
 /// </summary>
 /// <param name="offset"></param>
 internal override void SetOffset(Offset offset)
 {
     if (m_Dialog!=null)
         m_Dialog.SetOffset(offset);
 }