Merge pull request #3384 from jlewin/design_tools

Remove wrapping container, remove padding
This commit is contained in:
johnlewin 2018-06-05 18:12:48 -07:00 committed by GitHub
commit 0200f87c21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 47 additions and 42 deletions

View file

@ -2337,7 +2337,7 @@ namespace MatterHackers.MatterControl
{ {
UiThread.RunOnIdle(() => UiThread.RunOnIdle(() =>
{ {
DialogWindow.Show(new DesignSpaceGuide("Guides Tab", "")); DialogWindow.Show(new DesignSpaceGuide("AllGuides"));
}); });
} }

View file

@ -107,7 +107,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage
{ {
UiThread.RunOnIdle(() => UiThread.RunOnIdle(() =>
{ {
DialogWindow.Show(new DesignSpaceGuide("Guides Tab", "")); DialogWindow.Show(new DesignSpaceGuide("AllGuides"));
}); });
}); });

View file

@ -110,7 +110,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
seeWhatsNewButton.Click += (s, e) => UiThread.RunOnIdle(() => seeWhatsNewButton.Click += (s, e) => UiThread.RunOnIdle(() =>
{ {
UserSettings.Instance.set(UserSettingsKey.LastReadWhatsNew, JsonConvert.SerializeObject(DateTime.Now)); UserSettings.Instance.set(UserSettingsKey.LastReadWhatsNew, JsonConvert.SerializeObject(DateTime.Now));
DialogWindow.Show(new DesignSpaceGuide("What's New Tab", "")); DialogWindow.Show(new DesignSpaceGuide("What's New"));
}); });
tabControl.TabBar.ActionArea.AddChild(seeWhatsNewButton); tabControl.TabBar.ActionArea.AddChild(seeWhatsNewButton);

View file

@ -181,6 +181,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
{ {
this.ActiveTabChanged?.Invoke(this, null); this.ActiveTabChanged?.Invoke(this, null);
} }
internal int GetTabIndex(SimpleTab tab)
{
return _allTabs.IndexOf(tab);
}
} }
public class ChromeTabs : SimpleTabs public class ChromeTabs : SimpleTabs

View file

@ -613,7 +613,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
{ {
UiThread.RunOnIdle(() => UiThread.RunOnIdle(() =>
{ {
DialogWindow.Show(new DesignSpaceGuide("", "")); DialogWindow.Show(new DesignSpaceGuide());
}); });
} }
} }

View file

@ -119,9 +119,14 @@ namespace MatterHackers.MatterControl
DateTime installTime = new FileInfo(filePath).LastWriteTime; DateTime installTime = new FileInfo(filePath).LastWriteTime;
var lastReadWhatsNew = UserSettings.Instance.get(UserSettingsKey.LastReadWhatsNew); var lastReadWhatsNew = UserSettings.Instance.get(UserSettingsKey.LastReadWhatsNew);
DateTime whatsNewReadTime = installTime; DateTime whatsNewReadTime = installTime;
if (lastReadWhatsNew != null)
if (!string.IsNullOrWhiteSpace(lastReadWhatsNew))
{ {
whatsNewReadTime = JsonConvert.DeserializeObject<DateTime>(lastReadWhatsNew); try
{
whatsNewReadTime = JsonConvert.DeserializeObject<DateTime>(lastReadWhatsNew);
}
catch { }
} }
return whatsNewReadTime > installTime; return whatsNewReadTime > installTime;

View file

@ -81,31 +81,18 @@ namespace MatterHackers.MatterControl
public class DesignSpaceGuide : DialogPage public class DesignSpaceGuide : DialogPage
{ {
private List<GuideAsset> whatsNewGuides = new List<GuideAsset>(); private Dictionary<string, TreeNode> nodesByID;
private List<GuideAsset> allAvailableGuides = new List<GuideAsset>(); private TreeView treeView;
public DesignSpaceGuide(string guideKey = null)
public DesignSpaceGuide(string preSelectTabName, string guideKey)
: base("Close".Localize()) : base("Close".Localize())
{ {
WindowSize = new Vector2(800, 600); WindowSize = new Vector2(800, 600);
allAvailableGuides = ApplicationController.Instance.FeatureGuides;
// TODO: Guides document should have separate properties for differing top level containers
whatsNewGuides = allAvailableGuides;
this.WindowTitle = "MatterControl " + "Help".Localize(); this.WindowTitle = "MatterControl " + "Help".Localize();
this.HeaderText = "How to succeed with MatterControl".Localize(); this.HeaderText = "How to succeed with MatterControl".Localize();
this.ChildBorderColor = theme.GetBorderColor(75); this.ChildBorderColor = theme.GetBorderColor(75);
var container = new FlowLayoutWidget(FlowDirection.TopToBottom)
{
HAnchor = HAnchor.Stretch,
VAnchor = VAnchor.Stretch
};
contentRow.AddChild(container);
var tabControl = new SimpleTabs(theme, new GuiWidget()) var tabControl = new SimpleTabs(theme, new GuiWidget())
{ {
HAnchor = HAnchor.Stretch, HAnchor = HAnchor.Stretch,
@ -113,7 +100,8 @@ namespace MatterHackers.MatterControl
}; };
tabControl.TabBar.BackgroundColor = theme.TabBarBackground; tabControl.TabBar.BackgroundColor = theme.TabBarBackground;
container.AddChild(tabControl); contentRow.AddChild(tabControl);
contentRow.Padding = 0;
// add the mouse commands // add the mouse commands
var mouseControls = new FlowLayoutWidget() var mouseControls = new FlowLayoutWidget()
@ -231,6 +219,7 @@ namespace MatterHackers.MatterControl
VAnchor = VAnchor.Stretch, VAnchor = VAnchor.Stretch,
Padding = theme.DefaultContainerPadding Padding = theme.DefaultContainerPadding
}; };
var guideTab = new ToolTab("Guides".Localize(), tabControl, guideSectionContainer, theme, hasClose: false) var guideTab = new ToolTab("Guides".Localize(), tabControl, guideSectionContainer, theme, hasClose: false)
{ {
// this can be used to navigate to this tab on construction // this can be used to navigate to this tab on construction
@ -238,30 +227,30 @@ namespace MatterHackers.MatterControl
}; };
tabControl.AddTab(guideTab); tabControl.AddTab(guideTab);
AddGuides(guideSectionContainer, allAvailableGuides); AddGuides(guideSectionContainer);
tabControl.SelectedTabIndex = 0; // If guideKey is empty, switch to first tab
if(!string.IsNullOrWhiteSpace(preSelectTabName)) if (string.IsNullOrEmpty(guideKey))
{ {
// try to find the named tab tabControl.SelectedTabIndex = 0;
int index = 0; }
foreach(var tab in tabControl.AllTabs) else
{
// Otherwise switch to guides tab and select the target item
tabControl.SelectedTabIndex = tabControl.GetTabIndex(guideTab);
// TODO: Find the target TreeNode by ID and select
if (nodesByID.TryGetValue(guideKey, out TreeNode guideNode))
{ {
if (tab is GuiWidget widget) treeView.SelectedNode = guideNode;
{
if (widget.Name == preSelectTabName)
{
tabControl.SelectedTabIndex = index;
break;
}
}
index++;
} }
} }
} }
private void AddGuides(FlowLayoutWidget guideContainer, List<GuideAsset> guideList) private void AddGuides(FlowLayoutWidget guideContainer)
{ {
nodesByID = new Dictionary<string, TreeNode>();
var sequence = new ImageSequence() var sequence = new ImageSequence()
{ {
FramesPerSecond = 3, FramesPerSecond = 3,
@ -297,7 +286,7 @@ namespace MatterHackers.MatterControl
}; };
rightPanel.AddChild(description); rightPanel.AddChild(description);
var treeView = new TreeView(theme) treeView = new TreeView(theme)
{ {
HAnchor = HAnchor.Stretch, HAnchor = HAnchor.Stretch,
VAnchor = VAnchor.Fit | VAnchor.Top, VAnchor = VAnchor.Fit | VAnchor.Top,
@ -325,13 +314,17 @@ namespace MatterHackers.MatterControl
treeView.Load += (s, e) => treeView.Load += (s, e) =>
{ {
rootNode.Expanded = true; rootNode.Expanded = true;
treeView.SelectedNode = rootNode.Nodes.FirstOrDefault();
if (treeView.SelectedNode == null)
{
treeView.SelectedNode = rootNode.Nodes.FirstOrDefault();
}
}; };
TreeNode firstNode = null; TreeNode firstNode = null;
double maxMenuItemWidth = 0; double maxMenuItemWidth = 0;
foreach (var guide in guideList) foreach (var guide in ApplicationController.Instance.FeatureGuides.OrderBy(g => g.MenuName))
{ {
var treeNode = new TreeNode() var treeNode = new TreeNode()
{ {
@ -348,6 +341,8 @@ namespace MatterHackers.MatterControl
firstNode = treeNode; firstNode = treeNode;
} }
nodesByID.Add(guide.MenuName, treeNode);
rootNode.Nodes.Add(treeNode); rootNode.Nodes.Add(treeNode);
} }