示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ChangeOverlay"/> class with the specified
        /// <see cref="OverlayImage"/>.</summary>
        /// <param name="editing">
        /// <c>true</c> to edit the <see cref="EditorOptions.Overlay"/> defined by the current <see
        /// cref="EditorOptions"/>; <c>false</c> to edit the <see cref="AreaSection.Overlay"/>
        /// defined by the current <see cref="AreaSection"/>.</param>
        /// <exception cref="InvalidOperationException">
        /// <paramref name="editing"/> is <c>true</c>, and <see cref="ApplicationInfo.IsEditor"/> is
        /// <c>false</c>.</exception>
        /// <remarks>
        /// The data of the specified <see cref="OverlayImage"/> may be changed in the dialog, as
        /// indicated by the value of the <see cref="DataChanged"/> property.</remarks>

        public ChangeOverlay(bool editing)
        {
            if (editing)
            {
                ApplicationInfo.CheckEditor();
                this._overlay = ApplicationOptions.Instance.Editor.Overlay;
            }
            else
            {
                this._overlay = MasterSection.Instance.Areas.Overlay;
            }

            // copy original data for user cancellation
            this._originalOverlay = (OverlayImage)this._overlay.Clone();
            this._editing         = editing;

            InitializeComponent();

            // set maximum ranges for image coordinates
            LeftUpDown.Minimum = Int32.MinValue;
            LeftUpDown.Maximum = Int32.MaxValue;
            TopUpDown.Minimum  = Int32.MinValue;
            TopUpDown.Maximum  = Int32.MaxValue;

            WidthUpDown.Minimum  = 1;
            WidthUpDown.Maximum  = Int32.MaxValue;
            HeightUpDown.Minimum = 1;
            HeightUpDown.Maximum = Int32.MaxValue;

            // show current map dimensions at 100% scale
            var mapBounds = MapViewManager.Instance.MapGrid.DisplayBounds;

            MapWidthInfo.Text  = mapBounds.Width.ToString("N0", ApplicationInfo.Culture);
            MapHeightInfo.Text = mapBounds.Height.ToString("N0", ApplicationInfo.Culture);

            BorderWidthInfo.Text  = MapView.MapBorder.X.ToString("N0", ApplicationInfo.Culture);
            BorderHeightInfo.Text = MapView.MapBorder.Y.ToString("N0", ApplicationInfo.Culture);

            // initialize size if at default values
            if (this._overlay.Bounds.Width == 1 && this._overlay.Bounds.Height == 1)
            {
                this._overlay.Bounds = new RectI(
                    this._overlay.Bounds.Left, this._overlay.Bounds.Top,
                    Fortran.NInt(mapBounds.Width), Fortran.NInt(mapBounds.Height));
            }

            // show current overlay data
            ShowImagePath();
            ShowImageSize();
            AspectToggle.IsChecked = this._overlay.PreserveAspectRatio;

            LeftUpDown.Value   = this._overlay.Bounds.Left;
            TopUpDown.Value    = this._overlay.Bounds.Top;
            WidthUpDown.Value  = this._overlay.Bounds.Width;
            HeightUpDown.Value = this._overlay.Bounds.Height;

            // construction completed
            this._initialized = true;
        }