From b5edf403ba7d4be53ddd009e00a5e00af0fece2a Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Tue, 24 Apr 2018 10:15:01 -0700 Subject: [PATCH] Put in a quick pass at some help text. --- MatterControl.csproj | 1 + PartPreviewWindow/ViewControls3D.cs | 20 +--- SetupWizard/DesignSpaceHelp.cs | 179 ++++++++++++++++++++++++++++ 3 files changed, 182 insertions(+), 18 deletions(-) create mode 100644 SetupWizard/DesignSpaceHelp.cs diff --git a/MatterControl.csproj b/MatterControl.csproj index bc4fc3c74..7fb85275f 100644 --- a/MatterControl.csproj +++ b/MatterControl.csproj @@ -228,6 +228,7 @@ + diff --git a/PartPreviewWindow/ViewControls3D.cs b/PartPreviewWindow/ViewControls3D.cs index d438ad47e..f096ccb09 100644 --- a/PartPreviewWindow/ViewControls3D.cs +++ b/PartPreviewWindow/ViewControls3D.cs @@ -625,28 +625,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow new NamedAction() { Title = "----" }, new NamedAction() { - Title = "Keyboard Shotcuts".Localize(), + Title = "Help...".Localize(), Action = () => { UiThread.RunOnIdle(() => { - List<(string keys, string actoin)> keyAction = new List<(string keys, string actoin)>(new (string, string)[] - { - ("shift z","Zoom in"), - ("z","Zoom out"), - ("← → ↑ ↓","Rotate"), - ("shift ← → ↑ ↓","Pan"), - ("f","Zoom to fit"), - ("w","Zoom to window"), - ("ctrl / ⌘ z","Undo"), - ("ctrl / ⌘ y","Redo"), - ("delete","Delete selection"), - ("space bar","Clear selection"), - ("esc","Cancel command"), - ("enter","Accept command")}); - - // ("Keys","Action"); - DialogWindow.Show(); + DialogWindow.Show(); }); } } diff --git a/SetupWizard/DesignSpaceHelp.cs b/SetupWizard/DesignSpaceHelp.cs new file mode 100644 index 000000000..d5eb87e03 --- /dev/null +++ b/SetupWizard/DesignSpaceHelp.cs @@ -0,0 +1,179 @@ +/* +Copyright (c) 2016, Lars Brubaker +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The views and conclusions contained in the software and documentation are those +of the authors and should not be interpreted as representing official policies, +either expressed or implied, of the FreeBSD Project. +*/ + +using System; +using System.Collections.Generic; +using System.IO; +using MatterHackers.Agg; +using MatterHackers.Agg.UI; +using MatterHackers.Localizations; +using MatterHackers.MatterControl.SlicerConfiguration; + +namespace MatterHackers.MatterControl +{ + public class DesignSpaceHelp : DialogPage + { + FlowLayoutWidget mouseKeys; + FlowLayoutWidget keys; + FlowLayoutWidget mouseControls; + FlowLayoutWidget shortcutKeys; + + public DesignSpaceHelp() + : base("Close".Localize()) + { + this.WindowTitle = "Design Space Help".Localize(); + this.HeaderText = "Navigation Controls and Shortcut Keys".Localize(); + + var scrollWindow = new ScrollableWidget() + { + AutoScroll = true, + HAnchor = HAnchor.Stretch, + VAnchor = VAnchor.Stretch, + }; + scrollWindow.ScrollArea.HAnchor = HAnchor.Stretch; + contentRow.AddChild(scrollWindow); + + var container = new FlowLayoutWidget(FlowDirection.TopToBottom) + { + HAnchor = HAnchor.Stretch, + }; + scrollWindow.AddChild(container); + + // add the mouse commands + mouseControls = new FlowLayoutWidget() + { + HAnchor = HAnchor.Fit | HAnchor.Left + }; + container.AddChild(mouseControls); + + mouseKeys = new FlowLayoutWidget(FlowDirection.TopToBottom); + mouseControls.AddChild(mouseKeys); + + var mouseActions = new FlowLayoutWidget(FlowDirection.TopToBottom) + { + Border = new BorderDouble(3, 0, 0, 0), + BorderColor = Color.Black + }; + mouseControls.AddChild(mouseActions); + + List<(string key, string action)> mouseKeyActions = new List<(string key, string action)>(new(string, string)[] + { + ("ctrl left, right","Rotate".Localize()), + ("ctrl shift left, middle","Pan".Localize()), + ("wheel","Zoom".Localize()) + }); + + AddContent(mouseKeys, "Mouse".Localize(), true, true); + AddContent(mouseActions, "Action".Localize(), false, true); + + foreach (var keyAction in mouseKeyActions) + { + AddContent(mouseKeys, keyAction.key, true, false); + AddContent(mouseActions, keyAction.action, false, false); + } + + container.AddChild(new GuiWidget(10, 30)); + + // now add the keyboard commands + shortcutKeys = new FlowLayoutWidget() + { + HAnchor = HAnchor.Fit | HAnchor.Left + }; + + container.AddChild(shortcutKeys); + + keys = new FlowLayoutWidget(FlowDirection.TopToBottom); + shortcutKeys.AddChild(keys); + + var action = new FlowLayoutWidget(FlowDirection.TopToBottom) + { + Border = new BorderDouble(3, 0, 0, 0), + BorderColor = Color.Black + }; + shortcutKeys.AddChild(action); + + List<(string key, string action)> keyActions = new List<(string key, string action)>(new(string, string)[] + { + ("shift z","Zoom in".Localize()), + ("z","Zoom out".Localize()), + ("← → ↑ ↓","Rotate".Localize()), + ("shift ← → ↑ ↓","Pan".Localize()), + //("f","Zoom to fit".Localize()), + ("w","Zoom to window".Localize()), + ("ctrl / ⌘ z","Undo".Localize()), + ("ctrl / ⌘ y","Redo".Localize()), + ("delete","Delete selection".Localize()), + ("space bar","Clear selection".Localize()), + ("esc","Cancel command".Localize()), + //("enter","Accept command".Localize()) + }); + + AddContent(keys, "Keys".Localize(), true, true); + AddContent(action, "Action".Localize(), false, true); + + foreach (var keyAction in keyActions) + { + AddContent(keys, keyAction.key, true, false); + AddContent(action, keyAction.action, false, false); + } + } + + public override void OnBoundsChanged(EventArgs e) + { + // align the centers bars to the window center + var maxLeft = Math.Max(mouseKeys.Width, keys.Width); + + mouseControls.Margin = new BorderDouble(Width / 2 - maxLeft / 2, 0, 0, 0); + shortcutKeys.Margin = new BorderDouble(Width / 2 - maxLeft / 2, 0, 0, 0); + base.OnBoundsChanged(e); + } + + private void AddContent(GuiWidget column, string text, bool left, bool bold) + { + var container = new GuiWidget() + { + HAnchor = HAnchor.Fit | (left ? HAnchor.Right: HAnchor.Left), + VAnchor = VAnchor.Fit + }; + var content = new TextWidget(text, bold: bold) + { + Margin = (left ? new BorderDouble(5, 3, 10, 3) : new BorderDouble(10, 3, 5, 3)) + }; + container.AddChild(content); + + column.AddChild(container); + column.AddChild(new GuiWidget() + { + HAnchor = HAnchor.Stretch, + Border = new BorderDouble(0, 1, 0, 0), + BorderColor = Color.Black, + }); + } + } +} \ No newline at end of file