From 91df60adc90c6bcbc5f2a12080b1eec38858e6c5 Mon Sep 17 00:00:00 2001 From: jany-tenaj Date: Thu, 14 Sep 2017 14:15:13 +0200 Subject: [PATCH] - added possibility to show buttons from layout toolbars as checked while their function is active - added a default mouse cursor button to the insert toolbar --- Changelog.md | 2 + Source/DotSpatial.Controls/LayoutControl.cs | 205 ++++++++++++++---- Source/DotSpatial.Controls/LayoutEnums.cs | 2 +- .../LayoutForm.Designer.cs | 2 +- .../LayoutInsertToolStrip.Designer.cs | 13 +- .../LayoutInsertToolStrip.cs | 123 ++++++++--- Source/DotSpatial.Controls/LayoutMap.cs | 12 +- .../DotSpatial.Controls/LayoutMapToolStrip.cs | 18 +- Source/DotSpatial.Controls/LayoutScaleBar.cs | 2 +- .../MessageStrings.de-DE.resx | 120 +++++++++- .../DotSpatial.Controls/MessageStrings.resx | 3 + .../MessageStrings1.Designer.cs | 9 + 12 files changed, 402 insertions(+), 109 deletions(-) diff --git a/Changelog.md b/Changelog.md index 3a9664e4c..47858c51d 100644 --- a/Changelog.md +++ b/Changelog.md @@ -27,6 +27,7 @@ Be aware that code written for 1.9 will not work out of the box because DotSpati - FeatureLayer.Snappable to indicate whether the layer can be used for snapping - The possibility to draw linestrings which are inside a geometry collection (#1061) - The possibility to use static methods to deserialize objects that were serialized to a dspx file and can't be deserialized correctly via their class constructor (FeatureSet, MapSelfLoadGroup, MapSelfLoadLayers from GdalExtension, SpatiaLiteFeatureSet) (#1061) +- Default mouse cursor button in layout insert toolbar ### Changed - Switched to VS2015 and C#6 @@ -52,6 +53,7 @@ Be aware that code written for 1.9 will not work out of the box because DotSpati - If a dxf file contains points, lines and polygons at the same time, the dxf file gets added to the map as a group that contains one layer for points, one for lines and one for polygons (#1061) - If a dxf file contains only a single feature type the dxf file gets added to the map as a single layer with the feature type it contains (#1061) - dxf files get loaded with their styles (#1061) +- Show buttons from layout toolbars as checked while their function is active ### Removed - Removed DotSpatial.Topology assembly (#633) diff --git a/Source/DotSpatial.Controls/LayoutControl.cs b/Source/DotSpatial.Controls/LayoutControl.cs index 58d2b30e7..f52b19f6c 100644 --- a/Source/DotSpatial.Controls/LayoutControl.cs +++ b/Source/DotSpatial.Controls/LayoutControl.cs @@ -28,6 +28,8 @@ namespace DotSpatial.Controls public partial class LayoutControl : UserControl { #region Fields + private readonly List _otherToolStrips; + private LayoutElement _elementToAddWithMouse; private string _fileName; private PointF _lastMousePoint; @@ -45,7 +47,6 @@ public partial class LayoutControl : UserControl private bool _suppressLEinvalidate; private float _zoom; // The zoom of the paper - #endregion #region Constructors @@ -56,6 +57,7 @@ public partial class LayoutControl : UserControl public LayoutControl() { InitializeComponent(); + _otherToolStrips = new List(); _printerSettings = new PrinterSettings(); _fileName = string.Empty; _suppressLEinvalidate = false; @@ -81,6 +83,11 @@ public LayoutControl() #region Events + /// + /// This fires after a toolstrip has indicated that one of its buttons was checked. + /// + public event EventHandler ButtonChecked; + /// /// This fires after a element was added or removed. /// @@ -96,6 +103,11 @@ public LayoutControl() /// public event EventHandler LayoutLoaded; + /// + /// This fires after the mouse mode has changed. + /// + public event EventHandler MouseModeChanged; + /// /// This fires after the selection has changed. /// @@ -108,6 +120,31 @@ public LayoutControl() #endregion + #region Enums + + /// + /// Arten von MouseEvents, die an LayoutMap weitergeleitet werden können. + /// + public enum MouseEvent + { + /// + /// Mouse is down. + /// + Down = 1, + + /// + /// Mouse is moving. + /// + Move = 2, + + /// + /// Mouse is up. + /// + Up = 3 + } + + #endregion + #region Properties /// @@ -173,8 +210,15 @@ public LayoutInsertToolStrip LayoutInsertToolStrip set { if (value == null) return; + + if (_layoutInsertToolStrip != null) + { + _layoutInsertToolStrip.ButtonChecked -= OnButtonChecked; + } + _layoutInsertToolStrip = value; _layoutInsertToolStrip.LayoutControl = this; + _layoutInsertToolStrip.ButtonChecked += OnButtonChecked; } } @@ -269,28 +313,30 @@ public LayoutZoomToolStrip LayoutZoomToolStrip } /// - /// Gets or sets the Map control to use + /// Gets or sets the Map control to use. /// [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public Map MapControl { get; set; } /// - /// Gets or sets a value indicating whether the map is in pan mode. + /// Gets or sets the MouseMode. /// [Browsable(false)] - public bool MapPanMode + public MouseMode MouseMode { get { - if (_mouseMode == MouseMode.PanMap || _mouseMode == MouseMode.StartPanMap) - return true; - return false; + return _mouseMode; } set { - _mouseMode = value ? MouseMode.StartPanMap : MouseMode.Default; + if (_mouseMode != value) + { + _mouseMode = value; + OnMouseModeChanged(EventArgs.Empty); + } } } @@ -398,7 +444,7 @@ public void AddElementWithMouse(LayoutElement le) { _elementToAddWithMouse = le; ClearSelection(); - _mouseMode = MouseMode.StartInsertNewElement; + MouseMode = MouseMode.StartInsertNewElement; Cursor = Cursors.Cross; } @@ -424,6 +470,26 @@ public void AddToLayout(LayoutElement le) Invalidate(new Region(PaperToScreen(le.Rectangle))); } + /// + /// Assigns the given toolstrip to one of the ToolStrip propertys if it is of a corresponding type, otherwise it gets added to the list of tool strips that get checked for button changes. + /// + /// The tool strip that should be added. + public void AddToolStrip(LayoutToolStrip ts) + { + if (ts == null) return; + if (TrySet(ts, LayoutInsertToolStrip)) return; + if (TrySet(ts, LayoutZoomToolStrip)) return; + if (TrySet(ts, LayoutDocToolStrip)) return; + if (TrySet(ts, LayoutMapToolStrip)) return; + + if (!_otherToolStrips.Contains(ts)) + { + ts.LayoutControl = this; + ts.ButtonChecked += OnButtonChecked; + _otherToolStrips.Add(ts); + } + } + /// /// Aligns elements with each other or with the margins. /// @@ -554,6 +620,16 @@ public void AlignElements(List elements, Alignment side, bool mar } } + /// + /// Clears the current selection. + /// + public void ClearSelection() + { + SelectedLayoutElements.Clear(); + Invalidate(); + OnSelectionChanged(EventArgs.Empty); + } + /// /// Prepapres the layoutcontrol for closing, prompts the user to save if needed. /// @@ -1286,6 +1362,19 @@ public void RefreshElements() Invalidate(); } + /// + /// Removes the given tool strip from the list of tool strips that get checked for button changes. This does not remove tool strips that were assigned to a ToolStrip property. + /// + /// The toolstrip that should be removed. + public void RemoveToolStrip(LayoutToolStrip ts) + { + if (_otherToolStrips.Contains(ts)) + { + ts.ButtonChecked -= OnButtonChecked; + _otherToolStrips.Remove(ts); + } + } + /// /// Shows a save dialog box and prompts the user to save a layout file. /// @@ -1483,16 +1572,6 @@ internal void ClearLayout() Invalidate(); } - /// - /// Clears the current selection. - /// - internal void ClearSelection() - { - SelectedLayoutElements.Clear(); - Invalidate(); - OnSelectionChanged(EventArgs.Empty); - } - /// /// Removes the specified layoutElement from the layout. /// @@ -1569,7 +1648,7 @@ protected override void OnPaint(PaintEventArgs e) var le = LayoutElements[i]; // This code deals with drawins a map when its panning - if (_mouseMode == MouseMode.PanMap && SelectedLayoutElements.Contains(le) && le is LayoutMap && SelectedLayoutElements.Count == 1) + if (MouseMode == MouseMode.PanMap && SelectedLayoutElements.Contains(le) && le is LayoutMap && SelectedLayoutElements.Count == 1) { graph.TranslateTransform(_paperLocation.X + _mouseBox.Width, _paperLocation.Y + _mouseBox.Height); graph.ScaleTransform(96F / 100F * _zoom, 96F / 100F * _zoom); @@ -1634,9 +1713,9 @@ protected override void OnPaint(PaintEventArgs e) } // If the users is dragging a select box or an insert box we draw it here - if (_mouseMode == MouseMode.CreateSelection || _mouseMode == MouseMode.InsertNewElement) + if (MouseMode == MouseMode.CreateSelection || MouseMode == MouseMode.InsertNewElement) { - Color boxColor = _mouseMode == MouseMode.CreateSelection ? SystemColors.Highlight : Color.Orange; + Color boxColor = MouseMode == MouseMode.CreateSelection ? SystemColors.Highlight : Color.Orange; var outlinePen = new Pen(boxColor); var highlightBrush = new SolidBrush(Color.FromArgb(30, boxColor)); graph.FillRectangle(highlightBrush, _mouseBox.X, _mouseBox.Y, _mouseBox.Width - 1, _mouseBox.Height - 1); @@ -1904,14 +1983,14 @@ private void LayoutControlMouseDown(object sender, MouseEventArgs e) // Deals with left buttons clicks if (e.Button == MouseButtons.Left) { - switch (_mouseMode) + switch (MouseMode) { case MouseMode.Default: // Handles resizing stuff if (_resizeSelectedEdge != Edge.None) { - _mouseMode = MouseMode.ResizeSelected; + MouseMode = MouseMode.ResizeSelected; SelectedLayoutElements[0].Resizing = true; if (SelectedLayoutElements[0].ResizeStyle != ResizeStyle.HandledInternally) { @@ -1934,26 +2013,26 @@ private void LayoutControlMouseDown(object sender, MouseEventArgs e) foreach (var le in SelectedLayoutElements) { if (!le.IntersectsWith(mousePointPaper)) continue; - _mouseMode = MouseMode.MoveSelection; + MouseMode = MouseMode.MoveSelection; Cursor = Cursors.SizeAll; return; } } // Starts the selection code. - _mouseMode = MouseMode.CreateSelection; + MouseMode = MouseMode.CreateSelection; _mouseBox = new RectangleF(e.X, e.Y, 0F, 0F); break; // Start drag rectangle insert new element case MouseMode.StartInsertNewElement: - _mouseMode = MouseMode.InsertNewElement; + MouseMode = MouseMode.InsertNewElement; _mouseBox = new RectangleF(e.X, e.Y, 0F, 0F); break; // Starts the pan mode for the map case MouseMode.StartPanMap: - _mouseMode = MouseMode.PanMap; + MouseMode = MouseMode.PanMap; _mouseBox = new RectangleF(e.X, e.Y, 0F, 0F); break; } @@ -1962,11 +2041,11 @@ private void LayoutControlMouseDown(object sender, MouseEventArgs e) // Deals with right button clicks if (e.Button == MouseButtons.Right) { - switch (_mouseMode) + switch (MouseMode) { // If the user was in insert mode we cancel it case MouseMode.StartInsertNewElement: - _mouseMode = MouseMode.Default; + MouseMode = MouseMode.Default; _elementToAddWithMouse = null; Cursor = Cursors.Default; break; @@ -1983,7 +2062,7 @@ private void LayoutControlMouseMove(object sender, MouseEventArgs e) var inflate = 5F; // Handles various different mouse modes - switch (_mouseMode) + switch (MouseMode) { // Deals with inserting new elements case MouseMode.InsertNewElement: @@ -2135,7 +2214,7 @@ private void LayoutControlMouseUp(object sender, MouseEventArgs e) if (e.Button == MouseButtons.Left) { // Handles various different mouse modes - switch (_mouseMode) + switch (MouseMode) { // If we are dealing with a selection we look here case MouseMode.CreateSelection: @@ -2177,13 +2256,13 @@ private void LayoutControlMouseUp(object sender, MouseEventArgs e) } OnSelectionChanged(EventArgs.Empty); - _mouseMode = MouseMode.Default; + MouseMode = MouseMode.Default; Invalidate(); break; // Stops moving the selection case MouseMode.MoveSelection: - _mouseMode = MouseMode.Default; + MouseMode = MouseMode.Default; Cursor = Cursors.Default; break; @@ -2191,7 +2270,7 @@ private void LayoutControlMouseUp(object sender, MouseEventArgs e) case MouseMode.ResizeSelected: _resizeTempBitmap?.Dispose(); _resizeTempBitmap = null; - _mouseMode = MouseMode.Default; + MouseMode = MouseMode.Default; Cursor = Cursors.Default; SelectedLayoutElements[0].Resizing = false; SelectedLayoutElements[0].Size = SelectedLayoutElements[0].Size; @@ -2219,7 +2298,7 @@ private void LayoutControlMouseUp(object sender, MouseEventArgs e) AddToLayout(_elementToAddWithMouse); AddToSelection(_elementToAddWithMouse); _elementToAddWithMouse = null; - _mouseMode = MouseMode.Default; + MouseMode = MouseMode.Default; _mouseBox.Inflate(5, 5); Invalidate(new Region(_mouseBox)); break; @@ -2227,7 +2306,7 @@ private void LayoutControlMouseUp(object sender, MouseEventArgs e) case MouseMode.PanMap: if (_mouseBox.Width != 0 || _mouseBox.Height != 0) PanMap(SelectedLayoutElements[0] as LayoutMap, _mouseBox.Width, _mouseBox.Height); - _mouseMode = MouseMode.StartPanMap; + MouseMode = MouseMode.StartPanMap; break; case MouseMode.Default: @@ -2236,7 +2315,7 @@ private void LayoutControlMouseUp(object sender, MouseEventArgs e) } else if (e.Button == MouseButtons.Right) { - switch (_mouseMode) + switch (MouseMode) { case MouseMode.Default: if (SelectedLayoutElements.Count < 1) @@ -2306,6 +2385,16 @@ private void LeInvalidated(object sender, EventArgs e) Invalidate(); } + /// + /// Call this to indicated that a toolstrip has indicated that one of its buttons was checked. + /// + /// The toolstrip whose button was checked. + /// The event args. + private void OnButtonChecked(object sender, EventArgs e) + { + ButtonChecked?.Invoke(sender, e); + } + /// /// Call this to indicate elements were added or removed. /// @@ -2316,7 +2405,7 @@ private void OnElementsChanged(EventArgs e) } /// - /// Calls this to indicate the fileName has been changed. + /// Call this to indicate the fileName has been changed. /// /// The event args. private void OnFilenameChanged(EventArgs e) @@ -2333,6 +2422,15 @@ private void OnLayoutLoaded(EventArgs e) LayoutLoaded?.Invoke(this, e); } + /// + /// Call this to indicated that the mouse mode has changed. + /// + /// The event args. + private void OnMouseModeChanged(EventArgs e) + { + MouseModeChanged?.Invoke(this, e); + } + /// /// Call this to indicate the selection has changed. /// @@ -2348,13 +2446,13 @@ private void OnSelectionChanged(EventArgs e) else { _layoutMapToolStrip.Enabled = false; - if (_mouseMode == MouseMode.StartPanMap || _mouseMode == MouseMode.PanMap) - _mouseMode = MouseMode.Default; + if (MouseMode == MouseMode.StartPanMap || MouseMode == MouseMode.PanMap) + MouseMode = MouseMode.Default; } } - if (SelectedLayoutElements.Count == 0 && (_mouseMode == MouseMode.ResizeSelected || _mouseMode == MouseMode.MoveSelection)) - _mouseMode = MouseMode.Default; + if (SelectedLayoutElements.Count == 0 && (MouseMode == MouseMode.ResizeSelected || MouseMode == MouseMode.MoveSelection)) + MouseMode = MouseMode.Default; SelectionChanged?.Invoke(this, e); } @@ -2474,6 +2572,27 @@ private RectangleF ScreenToPaper(float screenX, float screenY, float screenW, fl return new RectangleF(paperTl.X, paperTl.Y, paperBr.X - paperTl.X, paperBr.Y - paperTl.Y); } + /// + /// Trys to assign the given tool strip to the given property. + /// + /// Type of the property. This is used to check whether ts has the same type. + /// The tool strip that should be assigned to the given property. + /// The property the tool strip should be assigned to. + /// True, if the tool strip could be assigned otherwise false. + // ReSharper disable once RedundantAssignment + // ReSharper disable once UnusedParameter.Local + private bool TrySet(ToolStrip ts, T property) + where T : class + { + var t = ts as T; + + if (t == null) return false; + + // ReSharper disable once RedundantAssignment + property = t; + return true; + } + /// /// Updates the scroll bars so the look and act right. /// diff --git a/Source/DotSpatial.Controls/LayoutEnums.cs b/Source/DotSpatial.Controls/LayoutEnums.cs index c879e59f0..d65ecffc8 100644 --- a/Source/DotSpatial.Controls/LayoutEnums.cs +++ b/Source/DotSpatial.Controls/LayoutEnums.cs @@ -125,7 +125,7 @@ public enum Fit /// /// An enumeration that defines the Mouses current behavior /// - internal enum MouseMode + public enum MouseMode { /// /// The cursor is currently in default mode diff --git a/Source/DotSpatial.Controls/LayoutForm.Designer.cs b/Source/DotSpatial.Controls/LayoutForm.Designer.cs index 423c1c13f..2efe00e13 100644 --- a/Source/DotSpatial.Controls/LayoutForm.Designer.cs +++ b/Source/DotSpatial.Controls/LayoutForm.Designer.cs @@ -113,7 +113,7 @@ private void InitializeComponent() this._layoutControl1.LayoutMenuStrip = this._layoutMenuStrip1; this._layoutControl1.LayoutPropertyGrip = this._layoutPropertyGrid1; this._layoutControl1.LayoutZoomToolStrip = this._layoutZoomToolStrip1; - this._layoutControl1.MapPanMode = false; + this._layoutControl1.MouseMode = MouseMode.Default; this._layoutControl1.Name = "_layoutControl1"; this._layoutControl1.ShowMargin = false; this._layoutControl1.Zoom = 0.3541667F; diff --git a/Source/DotSpatial.Controls/LayoutInsertToolStrip.Designer.cs b/Source/DotSpatial.Controls/LayoutInsertToolStrip.Designer.cs index a742251cc..fb8337e96 100644 --- a/Source/DotSpatial.Controls/LayoutInsertToolStrip.Designer.cs +++ b/Source/DotSpatial.Controls/LayoutInsertToolStrip.Designer.cs @@ -11,6 +11,7 @@ private void InitializeComponent() { this._btnMap = new ToolStripButton(); this._btnText = new ToolStripButton(); + this._btnDefault = new ToolStripButton(); this._btnRectangle = new ToolStripButton(); this._btnNorthArrow = new ToolStripButton(); this._btnBitmap = new ToolStripButton(); @@ -34,6 +35,14 @@ private void InitializeComponent() this._btnText.Text = MessageStrings.LayoutInsertToolStripText; this._btnText.Click += this.BtnTextClick; // + // _btnDefault + // + this._btnDefault.DisplayStyle = ToolStripItemDisplayStyle.Image; + this._btnDefault.Image = Images.cursor_arrow_16x16; + this._btnDefault.Size = new Size(23, 22); + this._btnDefault.Text = MessageStrings.LayoutInsertToolStripDefault; + this._btnDefault.Click += this.BtnDefaultClick; + // // _btnRectangle // this._btnRectangle.DisplayStyle = ToolStripItemDisplayStyle.Image; @@ -81,7 +90,8 @@ private void InitializeComponent() this._btnScaleBar, this._btnText, this._btnRectangle, - this._btnBitmap}); + this._btnBitmap, + this._btnDefault}); this.ResumeLayout(false); } @@ -94,5 +104,6 @@ private void InitializeComponent() private ToolStripButton _btnRectangle; private ToolStripButton _btnScaleBar; private ToolStripButton _btnText; + private ToolStripButton _btnDefault; } } diff --git a/Source/DotSpatial.Controls/LayoutInsertToolStrip.cs b/Source/DotSpatial.Controls/LayoutInsertToolStrip.cs index 69142eab4..17148dd7f 100644 --- a/Source/DotSpatial.Controls/LayoutInsertToolStrip.cs +++ b/Source/DotSpatial.Controls/LayoutInsertToolStrip.cs @@ -9,19 +9,12 @@ namespace DotSpatial.Controls { /// - /// A Brian Marchioni original toolstrip... preloaded with content. + /// This ToolStrip contains buttons that allow the insertion of layout elements. /// - // This control will no longer be visible [ToolboxItem(false)] - public partial class LayoutInsertToolStrip : ToolStrip + public partial class LayoutInsertToolStrip : LayoutToolStrip { - #region Fields - - private LayoutControl _layoutControl; - - #endregion - - #region Constructors + #region Constructors /// /// Initializes a new instance of the class. @@ -39,21 +32,26 @@ public LayoutInsertToolStrip() /// Gets or sets the layout control associated with this toolstrip. /// [Browsable(false)] - public LayoutControl LayoutControl + public override LayoutControl LayoutControl { get { - return _layoutControl; + return base.LayoutControl; } set { - if (value == null) + if (base.LayoutControl != null) { - throw new ArgumentOutOfRangeException(nameof(value)); + base.LayoutControl.MouseModeChanged -= LayoutControlMouseModeChanged; } - _layoutControl = value; + base.LayoutControl = value; + + if (base.LayoutControl != null) + { + base.LayoutControl.MouseModeChanged += LayoutControlMouseModeChanged; + } } } @@ -61,7 +59,11 @@ public LayoutControl LayoutControl #region Methods - // Fires the open method on the layoutcontrol + /// + /// Activates a function that allows the user to add a bitmap to the layout. + /// + /// The sender of the event. + /// The event args. private void BtnBitmapClick(object sender, EventArgs e) { using (var ofd = new OpenFileDialog @@ -78,22 +80,44 @@ private void BtnBitmapClick(object sender, EventArgs e) Size = new SizeF(100, 100), Filename = ofd.FileName }; - _layoutControl.AddElementWithMouse(newBitmap); + LayoutControl.AddElementWithMouse(newBitmap); + SetChecked(_btnBitmap); } } } + /// + /// Activates the default cursor. + /// + /// The sender of the event. + /// The event args. + private void BtnDefaultClick(object sender, EventArgs e) + { + LayoutControl.MouseMode = MouseMode.Default; + } + + /// + /// Activates a function that allows the user to add a legend to the layout. + /// + /// The sender of the event. + /// The event args. private void BtnLegendClick(object sender, EventArgs e) { - _layoutControl.AddElementWithMouse(_layoutControl.CreateLegendElement()); + LayoutControl.AddElementWithMouse(LayoutControl.CreateLegendElement()); + SetChecked(_btnLegend); } - // Fires the print method on the layoutcontrol + /// + /// Activates a function that allows the user to add a map to the layout. + /// + /// The sender of the event. + /// The event args. private void BtnMapClick(object sender, EventArgs e) { - if (_layoutControl.MapControl != null) + if (LayoutControl.MapControl != null) { - _layoutControl.AddElementWithMouse(_layoutControl.CreateMapElement()); + LayoutControl.AddElementWithMouse(LayoutControl.CreateMapElement()); + SetChecked(_btnMap); } else { @@ -101,28 +125,69 @@ private void BtnMapClick(object sender, EventArgs e) } } - // Fires the new method on the layoutcontrol + /// + /// Activates a function that allows the user to add a north arrow to the layout. + /// + /// The sender of the event. + /// The event args. private void BtnNorthArrowClick(object sender, EventArgs e) { - _layoutControl.AddElementWithMouse(new LayoutNorthArrow()); + LayoutControl.AddElementWithMouse(new LayoutNorthArrow()); + SetChecked(_btnNorthArrow); } - // Fires the save method on the layoutcontrol + /// + /// Activates a function that allows the user to add a rectangle to the layout. + /// + /// The sender of the event. + /// The event args. private void BtnRectangleClick(object sender, EventArgs e) { - _layoutControl.AddElementWithMouse(new LayoutRectangle()); + LayoutControl.AddElementWithMouse(new LayoutRectangle()); + SetChecked(_btnRectangle); } - // Adds a scale bar element to the layout and if there is already a map on the form we link it to the first one + /// + /// Activates a function that allows the user to add a scale bar to the layout. + /// + /// The sender of the event. + /// The event args. private void BtnScaleBarClick(object sender, EventArgs e) { - _layoutControl.AddElementWithMouse(_layoutControl.CreateScaleBarElement()); + LayoutControl.AddElementWithMouse(LayoutControl.CreateScaleBarElement()); + SetChecked(_btnScaleBar); } - // Fires the saveas method on the layoutcontrol + /// + /// Activates a function that allows the user to add some text to the layout. + /// + /// The sender of the event. + /// The event args. private void BtnTextClick(object sender, EventArgs e) { - _layoutControl.AddElementWithMouse(new LayoutText()); + LayoutControl.AddElementWithMouse(new LayoutText()); + SetChecked(_btnText); + } + + /// + /// Check the default button on default mousemode and uncheck all buttons if were not in insert mode. + /// + /// The sender of the event. + /// The event args. + private void LayoutControlMouseModeChanged(object sender, EventArgs e) + { + switch (LayoutControl.MouseMode) + { + case MouseMode.Default: + SetChecked(_btnDefault); + break; + case MouseMode.InsertNewElement: + case MouseMode.StartInsertNewElement: + break; + default: + UncheckAll(); + break; + } } #endregion diff --git a/Source/DotSpatial.Controls/LayoutMap.cs b/Source/DotSpatial.Controls/LayoutMap.cs index c81c28b5b..6909680c6 100644 --- a/Source/DotSpatial.Controls/LayoutMap.cs +++ b/Source/DotSpatial.Controls/LayoutMap.cs @@ -210,8 +210,6 @@ public virtual void ZoomOutMap() public virtual void ZoomToFullExtent() { Envelope = MapControl.Extent.ToEnvelope(); - OnThumbnailChanged(); - OnInvalidate(); } /// @@ -234,7 +232,7 @@ public virtual void ZoomViewExtent() /// protected override void OnSizeChanged() { - if (Resizing == false) + if (!Resizing) { // If the size has never been set before we set the maps extent to that of the map if (_oldRectangle.Width == 0 && _oldRectangle.Height == 0) @@ -246,18 +244,12 @@ protected override void OnSizeChanged() double dx = Envelope.Width / _oldRectangle.Width; double dy = Envelope.Height / _oldRectangle.Height; - //// Envelope newEnv = Envelope.Clone(); - //// newEnv.Width = newEnv.Width + ((Rectangle.Width - _oldRectangle.Width) * dx); - //// newEnv.Height = newEnv.Height + ((Rectangle.Height - _oldRectangle.Height) * dy); - //// newEnv.X = Envelope.X; - //// newEnv.Y = Envelope.Y; - //// Envelope = newEnv; double xtl = Envelope.MinX; double ytl = Envelope.MaxY; double width = Envelope.Width + ((Rectangle.Width - _oldRectangle.Width) * dx); double height = Envelope.Height + ((Rectangle.Height - _oldRectangle.Height) * dy); - Envelope.Init(xtl, xtl + width, ytl - height, ytl); + Envelope = new Envelope(xtl, xtl + width, ytl - height, ytl); // set a new envelope so the buffer gets recreated } _oldRectangle = new RectangleF(LocationF, Size); diff --git a/Source/DotSpatial.Controls/LayoutMapToolStrip.cs b/Source/DotSpatial.Controls/LayoutMapToolStrip.cs index c715de7a7..8d595fba5 100644 --- a/Source/DotSpatial.Controls/LayoutMapToolStrip.cs +++ b/Source/DotSpatial.Controls/LayoutMapToolStrip.cs @@ -3,7 +3,6 @@ using System; using System.ComponentModel; -using System.Windows.Forms; namespace DotSpatial.Controls { @@ -12,7 +11,7 @@ namespace DotSpatial.Controls /// // This control will no longer be visible [ToolboxItem(false)] - public partial class LayoutMapToolStrip : ToolStrip + public partial class LayoutMapToolStrip : LayoutToolStrip { #region Constructors @@ -26,22 +25,13 @@ public LayoutMapToolStrip() #endregion - #region Properties - - /// - /// Gets or sets the layout control associated with this toolstrip. - /// - [Browsable(false)] - public LayoutControl LayoutControl { get; set; } - - #endregion - #region Methods - // Fires when the user clicks the pan button + // Fires when the user clicks the pan button. private void BtnPanClick(object sender, EventArgs e) { - LayoutControl.MapPanMode = _btnPan.Checked; + LayoutControl.MouseMode = MouseMode.StartPanMap; + SetChecked(_btnPan); } // Fires when the user clicks the zoom to full extent button diff --git a/Source/DotSpatial.Controls/LayoutScaleBar.cs b/Source/DotSpatial.Controls/LayoutScaleBar.cs index f799721cc..f59d53039 100644 --- a/Source/DotSpatial.Controls/LayoutScaleBar.cs +++ b/Source/DotSpatial.Controls/LayoutScaleBar.cs @@ -275,7 +275,7 @@ public override void Draw(Graphics g, bool printing) g.DrawLine(scalePen, leftStart, fontHeight * 1.6f, leftStart + (breakWidth * _numBreaks), fontHeight * 1.6f); - g.DrawString("1 : " + string.Format("{0:0, }", Map.Scale), _font, scaleBrush, leftStart - (g.MeasureString(Math.Abs(geoBreakWidth * startBreak).ToString(), _font).Width / 2), fontHeight * 2.5F); + g.DrawString("1 : " + string.Format("{0:0,0}", Map.Scale), _font, scaleBrush, leftStart - (g.MeasureString(Math.Abs(geoBreakWidth * startBreak).ToString(), _font).Width / 2), fontHeight * 2.5F); for (int i = startBreak; i <= _numBreaks + startBreak; i++) { diff --git a/Source/DotSpatial.Controls/MessageStrings.de-DE.resx b/Source/DotSpatial.Controls/MessageStrings.de-DE.resx index 1fe33a42d..b0e7c655e 100644 --- a/Source/DotSpatial.Controls/MessageStrings.de-DE.resx +++ b/Source/DotSpatial.Controls/MessageStrings.de-DE.resx @@ -324,24 +324,48 @@ Soll das Koordinatensystem des Layers an das Koordinatensystem der Map angepasst Layer hinzufügen... + + Neues Projekt anlegen? + + + Tragen Sie den Text ein, der in der Legende angezeigt werden soll. + Dies sollte eine ganze Zahl zwischen 0 und 15 sein. - - Alles abwählen + + Bestätigen + + + Kopiere Werte + + + Kopiere Werte von %S1 zu %S2 + + + Kopiere Werte von %S1 + + + Kopiere Werte von %S1 zu %S2 Änderungen verwerfen? + + Alle abwählen + Fehler - Fehler bei der Aktivierung von {0}. + Fehler beim Aktivieren von {0}. Ausdruck + + Erweiterungen + Alle Features @@ -349,30 +373,108 @@ Soll das Koordinatensystem des Layers an das Koordinatensystem der Map angepasst Ausgewählte Features - &Datei + Datei - &Beenden + Schließen - &Neu + Neu - Ö&ffnen... + Öffnen... Drucklayout... + + Fensterlayout zurücksetzen + - &Speichern + Speichern - Speichern &unter... + Speichern unter... Die Datei %S existiert bereits. Soll sie überschrieben werden? + + Die Datei %S konnte nicht gefunden werden. + + + Suchen + + + Eingabe + + + Auf den ausgewählten Layer zoomen + + + Auf volle Ausdehnung zoomen + + + Volle Ausdehnung + + + Auf Koordinate zoomen + + + Rückgängig + + + Zoomen + + + Vergrößern + + + Verkleinern + + + Verkleinern + + + Vergrößern + + + Wiederholen + + + Änderungen speichern? + + + Layer speichern... + + + Ausgewählten Layer entfernen + + + Projekt-Datei + + + Bewegen + + + Nächste Ansicht + + + Vorherige Ansicht + + + Auswählen + + + Legende + + + Abweichendes Koordinatensystem + Einstellungen + + Standard-Mauszeiger + \ No newline at end of file diff --git a/Source/DotSpatial.Controls/MessageStrings.resx b/Source/DotSpatial.Controls/MessageStrings.resx index 3f137a4d9..28a13362f 100644 --- a/Source/DotSpatial.Controls/MessageStrings.resx +++ b/Source/DotSpatial.Controls/MessageStrings.resx @@ -1000,4 +1000,7 @@ Load the layout with the printer's current paper settings? Missing MapControl + + Default mouse cursor + \ No newline at end of file diff --git a/Source/DotSpatial.Controls/MessageStrings1.Designer.cs b/Source/DotSpatial.Controls/MessageStrings1.Designer.cs index 8d1835540..ca0315024 100644 --- a/Source/DotSpatial.Controls/MessageStrings1.Designer.cs +++ b/Source/DotSpatial.Controls/MessageStrings1.Designer.cs @@ -1242,6 +1242,15 @@ internal static string LayoutInsertToolStripBitmap { } } + /// + /// Looks up a localized string similar to Default mouse cursor. + /// + internal static string LayoutInsertToolStripDefault { + get { + return ResourceManager.GetString("LayoutInsertToolStripDefault", resourceCulture); + } + } + /// /// Looks up a localized string similar to Insert map. ///