Beispiel #1
0
        private void previewTimer_Tick(object sender, EventArgs e)
        {
            // Stop the timer - the user has to make a further change to the entered path
            // in order to rework the auto-preview
            previewTimer.Stop();
            okButton.Enabled = false;

            // If there's any problem working out the preview, we won't draw the path
            m_DrawPath = false;

            try
            {
                // Don't use ParsePath, as that may display a message box
                string str = GetEnteredPath();
                m_Items = PathParser.GetPathItems(str, EditingController.Current.EntryUnit);

                if (m_Items.Length > 0)
                {
                    Leg[] legs = PathParser.CreateLegs(m_Items);
                    m_PathData = new PathInfo(m_From, m_To, legs);

                    double prec = m_PathData.Precision;
                    if (Math.Abs(prec) < MathConstants.TINY)
                    {
                        previewLabel.Text = "Exact fit";
                    }
                    else
                    {
                        previewLabel.Text = String.Format("1:{0}", (uint)prec);
                    }

                    m_DrawPath = true;
                    m_Command.ErasePainting();

                    okButton.Enabled = true;
                }
            }

            // Indicate that the path cannot be parsed (in the case of an ApplicationException, assume
            // the exception message is informational).

            catch (ApplicationException ae)
            {
                previewLabel.Text = ae.Message;
            }

            catch (Exception)
            {
                previewLabel.Text = "Cannot generate preview";
            }
        }
Beispiel #2
0
        /// <summary>
        /// Parses the string that represents the path description.
        /// </summary>
        /// <param name="str">The string to parse</param>
        /// <returns>True if the supplied string is understandable</returns>
        bool ParseString(string str)
        {
            try
            {
                m_Items = PathParser.GetPathItems(str, EditingController.Current.EntryUnit);
                return(true);
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            return(false);
        }