Exemple #1
0
        public MainForm(string[] args)
        {
            InitializeComponent();

            // Define the controller for the application
            m_Controller = new EditingController(this);

            string regkey = @"Software\Backsight\Editor\MRU";
            m_MruMenu = new MruStripMenuInline(mnuFile, mnuFileRecent, new MruStripMenu.ClickedHandler(OnMruFile), regkey, 10);

            // Hide property panel unless it's requested
            vSplitContainer.Panel2Collapsed = true;

            // Hide command panel unless a command is running
            hSplitContainer.Panel2Collapsed = true;

            // Can't seem to specify shortcut keys involving the "Enter" key at design time
            // ...leads to error starting up (something about invalid enum values)
            //mnuEditRepeat.ShortcutKeys = Keys.Enter;
            //mnuEditRecall.ShortcutKeys = Keys.Alt | Keys.Enter;

            // All user interface actions should be handled via the UserActionList technique.
            // Those that deal with map navigation get routed to the map control, the rest
            // will get routed to methods in this class.

            m_Actions = new UserActionList();
        }
Exemple #2
0
        void ShowResults(DistanceUnitType type)
        {
            DistanceUnit unit = EditingController.GetUnits(type);

            if (unit == null)
            {
                return;
            }

            lengthLabel.Text        = unit.Format(m_Length, false, -1);
            deltaNorthingLabel.Text = unit.Format(m_DeltaN, false, -1);
            deltaEastingLabel.Text  = unit.Format(m_DeltaE, false, -1);
        }
Exemple #3
0
        private void InverseForm_Shown(object sender, EventArgs e)
        {
            // Display at top left corner of the screen.
            //this->SetWindowPos( &wndTopMost, 0,0, 0,0, SWP_NOSIZE );

            // Display the adjustment results in the current display
            // units. If the display units are "as entered", use
            // the current data entry units instead.

            EditingController ec      = EditingController.Current;
            DistanceUnit      display = ec.DisplayUnit;

            m_Unit = (display.UnitType == DistanceUnitType.AsEntered ? ec.EntryUnit : display);
            InitializeUnits(m_Unit);
        }
Exemple #4
0
        /// <summary>
        /// Constructor that accepts a string. Use the <c>IsDefined</c> property to check
        /// whether the string was parsed ok. Also see <see cref="TryParse"/>.
        /// </summary>
        /// <param name="s">The string to parse. It should look like a floating
        ///	point number, but may have a units abbreviation stuck on the end (like that
        ///	produced by <c>Distance.Format</c>).</param>
        ///	<param name="defaultEntryUnit">The default units</param>
        internal Distance(string str, DistanceUnit defaultEntryUnit)
        {
            // Initialize with undefined values.
            m_ObservedMetric    = 0.0;
            m_EnteredUnit       = null;
            m_IsFixed           = false;
            IsAnnotationFlipped = false;

            // Ignore any trailing white space. Return if it's ALL white space.
            string s = str.Trim();

            if (s.Length == 0)
            {
                return;
            }

            // Split the string into a numeric & abbreviation part
            string num, abbr;

            ParseDistanceString(str, out num, out abbr);

            // Try to convert the entered string to a float.
            double dval;

            if (!Double.TryParse(num, out dval))
            {
                return;
            }

            // If the abbreviation corresponds to some form a data entry, save the
            // entered distance in those. Otherwise save in the supplied data entry units.
            if (abbr.Length > 0)
            {
                EditingController ec = EditingController.Current;
                m_EnteredUnit = ec.GetUnit(abbr);
                if (m_EnteredUnit != null)
                {
                    m_ObservedMetric = m_EnteredUnit.ToMetric(dval);
                }
            }
            else
            {
                m_ObservedMetric = defaultEntryUnit.ToMetric(dval);
                m_EnteredUnit    = defaultEntryUnit;
            }
        }
Exemple #5
0
        /// <summary>
        /// Runs a trim dangles command by creating the editing operation (using the current feature
        /// selection) & executing it. The controller is then told to clear the selection before
        /// completing the command.
        /// </summary>
        /// <returns>True if the command ran to completion. False if any exception arose (in that
        /// case, the controller would be told to abort the command).</returns>
        internal override bool Run()
        {
            // Grab the current selection & filter out stuff that can't be trimmed
            EditingController c  = Controller;
            ISpatialSelection ss = c.SpatialSelection;

            LineFeature[] lines = TrimLineOperation.PreCheck(ss.Items);
            if (lines.Length == 0)
            {
                StringBuilder sb = new StringBuilder(200);
                sb.Append("Nothing can be trimmed. Possible reasons:");
                sb.Append(System.Environment.NewLine);
                sb.Append(System.Environment.NewLine);
                sb.Append("1. Lines have to be dangling.");
                sb.Append(System.Environment.NewLine);
                sb.Append("2. Only lines that are polygon boundaries can be trimmed.");
                sb.Append(System.Environment.NewLine);
                sb.Append("3. There has to be something left after trimming a line.");

                MessageBox.Show(sb.ToString());
                c.AbortCommand(this);
                return(false);
            }

            TrimLineOperation op = null;

            try
            {
                op = new TrimLineOperation();
                op.Execute(lines);

                c.ClearSelection();
                c.FinishCommand(this);
                return(true);
            }

            catch (Exception e)
            {
                MessageBox.Show(e.StackTrace, e.Message);
                c.AbortCommand(this);
                return(false);
            }
        }
Exemple #6
0
        /// <summary>
        /// Starts the user interface (if any) for this command. This will change the
        /// topological status of the line that was passed to the constructor, then
        /// complete the command.
        /// </summary>
        /// <returns>True if command started (and completed) ok.</returns>
        internal override bool Run()
        {
            EditingController    c  = Controller;
            SetTopologyOperation op = null;

            try
            {
                op = new SetTopologyOperation(m_Line);
                op.Execute();
                c.ClearSelection();
                c.FinishCommand(this);
                return(true);
            }

            catch (Exception e)
            {
                c.AbortCommand(this);
                MessageBox.Show(e.StackTrace, e.Message);
            }

            return(false);
        }
Exemple #7
0
        //=========================================================================================
        public CodeViewer()
        {
            this.BackColor = SystemColors.Window;
            this._Language = PredefinedLanguage.None;
            this.Document  = new Document();
            this.Spans     = new TextSpanCollection(this);
            this.InitializeComponent();
            this.SetDefaultFont();

            this.SetStyle(ControlStyles.DoubleBuffer, true);
            this.SetStyle(ControlStyles.UserPaint, true);
            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            this.SetStyle(ControlStyles.ResizeRedraw, true);

            this.EditController = new EditingController(this);
            this._Body.SetOwner(this);

            this._Body.KeyDown   += new KeyEventHandler(_Body_KeyDown);
            this._Body.KeyUp     += new KeyEventHandler(_Body_KeyUp);
            this._Body.MouseDown += new MouseEventHandler(_Body_MouseDown);

            this._Body.TextChanged += new EventHandler(_Body_TextChanged);
        }
Exemple #8
0
        internal override void MouseMove(IPosition p)
        {
            PointFeature      oldCurrentPoint = m_CurrentPoint;
            CadastralMapModel map             = CadastralMapModel.Current;
            EditingController ec   = EditingController.Current;
            ILength           size = new Length(ec.Project.Settings.PointHeight * 0.5);

            m_CurrentPoint = (map.QueryClosest(p, size, SpatialType.Point) as PointFeature);

            if (m_Start == null)
            {
                // If the mouse is over a different point, ensure the old point is erased
                if (oldCurrentPoint != null && !Object.ReferenceEquals(oldCurrentPoint, m_CurrentPoint))
                {
                    ErasePainting();
                }

                return;
            }

            if (m_CurrentPoint == null)
            {
                m_End = PointGeometry.Create(p);
            }
            else
            {
                m_End = m_CurrentPoint;
            }

            if (m_End.IsCoincident(m_Start))
            {
                m_End = null;
                return;
            }

            ErasePainting();
        }
Exemple #9
0
        void LoadNtx(string ntxFile)
        {
            Debug.Assert(CadastralMapModel.Current.WorkingSession != null);

            // If the model is currently empty, we'll want to draw an overview upon
            // completion of the import (otherwise we'll refresh using the currently
            // displayed extent).
            bool wasEmpty = CadastralMapModel.Current.IsEmpty;

            ImportOperation   i = null;
            EditingController c = EditingController.Current;

            try
            {
                i = new ImportOperation();
                NtxImport ni = new NtxImport(ntxFile, this);
                i.Execute(ni);
                Trace.Write("Map model updates completed");
            }

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

            if (wasEmpty)
            {
                c.ActiveDisplay.DrawOverview();
            }
            else
            {
                c.RefreshAllDisplays();
            }

            SaveTranslations();
        }
Exemple #10
0
 void SetUnit(DistanceUnitType type)
 {
     m_Unit = EditingController.GetUnits(type);
 }
Exemple #11
0
 private void cRadioButton_CheckedChanged(object sender, EventArgs e)
 {
     m_Unit = EditingController.GetUnits(DistanceUnitType.Chains);
     SetNewDefault();
 }