Merge pull request #3458 from jlewin/design_tools
Add Garbage Collector helper in debug to aid in memory troubleshooting
This commit is contained in:
commit
32bd0bd2ee
9 changed files with 147 additions and 66 deletions
|
|
@ -116,7 +116,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
public class ApplicationController
|
||||
{
|
||||
public List<GuideAsset> FeatureGuides { get; set; } = JsonConvert.DeserializeObject<List<GuideAsset>>(AggContext.StaticData.ReadAllText(Path.Combine("OEMSettings", "HelpGuides.json")));
|
||||
public List<GuideAsset> FeatureGuides { get; set; }
|
||||
|
||||
private Dictionary<Type, HashSet<IObject3DEditor>> objectEditorsByType;
|
||||
|
||||
|
|
@ -666,6 +666,20 @@ namespace MatterHackers.MatterControl
|
|||
this.Theme = new ThemeConfig();
|
||||
this.MenuTheme = new ThemeConfig();
|
||||
|
||||
List<GuideAsset> helpGuides = null;
|
||||
|
||||
string helpGuidesPath = Path.Combine("OEMSettings", "HelpGuides.json");
|
||||
if (AggContext.StaticData.FileExists(helpGuidesPath))
|
||||
{
|
||||
try
|
||||
{
|
||||
helpGuides = JsonConvert.DeserializeObject<List<GuideAsset>>(AggContext.StaticData.ReadAllText(helpGuidesPath));
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
this.FeatureGuides = helpGuides ?? new List<GuideAsset>();
|
||||
|
||||
ActiveTheme.ThemeChanged.RegisterEvent((s, e) =>
|
||||
{
|
||||
ChangeToTheme(ActiveTheme.Instance);
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ namespace MatterHackers.MatterControl.Library
|
|||
if (Directory.Exists(this.FullPath))
|
||||
{
|
||||
var recentFiles = new DirectoryInfo(this.FullPath).GetFiles("*.mcx").OrderByDescending(f => f.LastWriteTime);
|
||||
Items = recentFiles.Take(this.PageSize).Select(f => new FileSystemFileItem(f.FullName)).ToList<ILibraryItem>();
|
||||
Items = recentFiles.Where(f => f.Length > 500).Take(this.PageSize).Select(f => new FileSystemFileItem(f.FullName)).ToList<ILibraryItem>();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -128,6 +128,7 @@
|
|||
<Compile Include="PartPreviewWindow\GCodeDetails\IToggleOption.cs" />
|
||||
<Compile Include="PartPreviewWindow\LeftClipFlowLayoutWidget.cs" />
|
||||
<Compile Include="PartPreviewWindow\Object3DTreeBuilder.cs" />
|
||||
<Compile Include="PartPreviewWindow\ResizableSectionWidget.cs" />
|
||||
<Compile Include="PartPreviewWindow\StartPage\FeedData.cs" />
|
||||
<Compile Include="PartPreviewWindow\StartPage\FeedItemData.cs" />
|
||||
<Compile Include="PartPreviewWindow\StartPage\FeedSectionData.cs" />
|
||||
|
|
|
|||
83
PartPreviewWindow/ResizableSectionWidget.cs
Normal file
83
PartPreviewWindow/ResizableSectionWidget.cs
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
Copyright (c) 2018, Lars Brubaker, John Lewin
|
||||
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 MatterHackers.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.MatterControl.CustomWidgets;
|
||||
|
||||
namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||
{
|
||||
public class ResizableSectionWidget : SectionWidget
|
||||
{
|
||||
public BottomResizeContainer ResizeContainer { get; }
|
||||
|
||||
public event EventHandler Resized;
|
||||
|
||||
public ResizableSectionWidget(string sectionTitle, double initialHeight, GuiWidget sectionContent, ThemeConfig theme, GuiWidget rightAlignedContent = null, int headingPointSize = -1, bool expandingContent = true, bool expanded = true, string serializationKey = null, bool defaultExpansion = false, bool setContentVAnchor = true)
|
||||
: base(sectionTitle, new GuiWidget(), theme, rightAlignedContent, headingPointSize, expanded, expanded, serializationKey, defaultExpansion, setContentVAnchor)
|
||||
{
|
||||
this.VAnchor = VAnchor.Fit;
|
||||
|
||||
this.ResizeContainer = new BottomResizeContainer(theme)
|
||||
{
|
||||
HAnchor = HAnchor.Stretch,
|
||||
VAnchor = VAnchor.Absolute,
|
||||
Height = initialHeight
|
||||
};
|
||||
|
||||
this.ResizeContainer.Resized += (s, e) =>
|
||||
{
|
||||
this.Resized?.Invoke(this, null);
|
||||
};
|
||||
|
||||
// Add container used to host the current specialized editor for the selection
|
||||
var scrollableWidget = new ScrollableWidget(true)
|
||||
{
|
||||
HAnchor = HAnchor.Stretch,
|
||||
VAnchor = VAnchor.Stretch
|
||||
};
|
||||
scrollableWidget.AddChild(sectionContent);
|
||||
scrollableWidget.ScrollArea.HAnchor = HAnchor.Stretch;
|
||||
|
||||
this.ResizeContainer.AddChild(scrollableWidget);
|
||||
|
||||
// A wrapping container to fix resize quirks - GuiWidget with H:Stretch V:Fit that can be hidden and shown and allow the ResizeContainer can keep it's size
|
||||
var resizeWrapper = new GuiWidget()
|
||||
{
|
||||
HAnchor = HAnchor.Stretch,
|
||||
VAnchor = VAnchor.Fit,
|
||||
Name = "editorRootContainer"
|
||||
};
|
||||
resizeWrapper.AddChild(this.ResizeContainer);
|
||||
|
||||
this.SetContentWidget(resizeWrapper);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -52,12 +52,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
private ThemeConfig theme;
|
||||
private BedConfig sceneContext;
|
||||
private View3DWidget view3DWidget;
|
||||
private SectionWidget editorSectionWidget;
|
||||
private ResizableSectionWidget editorSectionWidget;
|
||||
private TextButton editButton;
|
||||
|
||||
private GuiWidget editorPanel;
|
||||
private InlineTitleEdit inlineTitleEdit;
|
||||
private BottomResizeContainer editorResizeContainer;
|
||||
|
||||
public SelectedObjectPanel(View3DWidget view3DWidget, BedConfig sceneContext, ThemeConfig theme)
|
||||
: base(FlowDirection.TopToBottom)
|
||||
|
|
@ -87,25 +86,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
this.AddChild(scrollable);
|
||||
|
||||
editorResizeContainer = new BottomResizeContainer(theme)
|
||||
{
|
||||
HAnchor = HAnchor.Stretch,
|
||||
VAnchor = VAnchor.Absolute,
|
||||
Height = sceneContext.ViewState.SelectedObjectEditorHeight
|
||||
};
|
||||
|
||||
var toolbar = new Toolbar(theme)
|
||||
{
|
||||
Padding = theme.ToolbarPadding,
|
||||
HAnchor = HAnchor.Stretch,
|
||||
VAnchor = VAnchor.Fit
|
||||
};
|
||||
editorResizeContainer.AddChild(toolbar);
|
||||
|
||||
editorResizeContainer.Resized += (s, e) =>
|
||||
{
|
||||
sceneContext.ViewState.SelectedObjectEditorHeight = editorResizeContainer.Height;
|
||||
};
|
||||
|
||||
var scene = sceneContext.Scene;
|
||||
|
||||
|
|
@ -185,31 +171,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
scene.SelectionChanged += (s, e) => removeButton.Enabled = scene.SelectedItem?.CanRemove == true;
|
||||
toolbar.AddChild(removeButton);
|
||||
|
||||
// Add container used to host the current specialized editor for the selection
|
||||
var scrollableEditor = new ScrollableWidget(true)
|
||||
{
|
||||
HAnchor = HAnchor.Stretch,
|
||||
VAnchor = VAnchor.Stretch
|
||||
};
|
||||
scrollableEditor.AddChild(editorPanel = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
||||
editorPanel = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
||||
{
|
||||
HAnchor = HAnchor.Stretch,
|
||||
VAnchor = VAnchor.Fit,
|
||||
Padding = new BorderDouble(top: 10)
|
||||
});
|
||||
scrollableEditor.ScrollArea.HAnchor = HAnchor.Stretch;
|
||||
|
||||
editorResizeContainer.AddChild(scrollableEditor);
|
||||
|
||||
// A wrapping container to fix resize quirks - GuiWidget with H:Stretch V:Fit that can be hidden and shown and allow the ResizeContainer can keep it's size
|
||||
var editorResizeWrapper = new GuiWidget()
|
||||
{
|
||||
HAnchor = HAnchor.Stretch,
|
||||
VAnchor = VAnchor.Fit,
|
||||
Name = "editorRootContainer"
|
||||
};
|
||||
editorResizeWrapper.AddChild(editorResizeContainer);
|
||||
|
||||
inlineTitleEdit = new InlineTitleEdit("", theme, "Object Name");
|
||||
inlineTitleEdit.TitleChanged += (s, e) =>
|
||||
{
|
||||
|
|
@ -219,10 +186,16 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
}
|
||||
};
|
||||
|
||||
editorSectionWidget = new SectionWidget("Editor", editorResizeWrapper, theme, serializationKey: UserSettingsKey.EditorPanelExpanded, defaultExpansion: true)
|
||||
editorSectionWidget = new ResizableSectionWidget("Editor", sceneContext.ViewState.SelectedObjectEditorHeight, editorPanel, theme, serializationKey: UserSettingsKey.EditorPanelExpanded, defaultExpansion: true)
|
||||
{
|
||||
VAnchor = VAnchor.Fit,
|
||||
};
|
||||
editorSectionWidget.Resized += (s, e) =>
|
||||
{
|
||||
sceneContext.ViewState.SelectedObjectEditorHeight = editorSectionWidget.ResizeContainer.Height;
|
||||
};
|
||||
|
||||
editorSectionWidget.ResizeContainer.AddChild(toolbar, 0);
|
||||
|
||||
// TODO: Replace hackery with practical solution
|
||||
if (editorSectionWidget.Children.FirstOrDefault() is ExpandCheckboxButton checkbox)
|
||||
|
|
@ -267,10 +240,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
foreach(var sectionWidget in this.ContentPanel.Children<SectionWidget>())
|
||||
{
|
||||
// Special case for editorResizeWrapper due to ResizeContainer
|
||||
if (sectionWidget.ContentPanel == editorResizeWrapper)
|
||||
if (sectionWidget is ResizableSectionWidget resizableSectionWidget)
|
||||
{
|
||||
// Apply padding to ResizeContainer not wrapper
|
||||
editorResizeContainer.Padding = new BorderDouble(10, 10, 10, 0);
|
||||
resizableSectionWidget.ResizeContainer.Padding = new BorderDouble(10, 10, 10, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
|
|||
{
|
||||
FeedData explorerFeed = null;
|
||||
|
||||
var json = ApplicationController.LoadCachedFile(staticFile, "MatterHackers");
|
||||
var json = ApplicationController.LoadCachedFile("MatterHackers", staticFile);
|
||||
if (json != null)
|
||||
{
|
||||
// Construct directly from cache
|
||||
|
|
|
|||
|
|
@ -182,21 +182,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
VAnchor = VAnchor.Fit,
|
||||
});
|
||||
|
||||
treeSection = new BottomResizeContainer(theme)
|
||||
{
|
||||
HAnchor = HAnchor.Stretch,
|
||||
VAnchor = VAnchor.Absolute,
|
||||
Height = sceneContext.ViewState.SceneTreeHeight
|
||||
};
|
||||
modelViewSidePanel.AddChild(treeSection);
|
||||
|
||||
// add the tree view
|
||||
treeView = new TreeView(theme)
|
||||
{
|
||||
TextColor = theme.Colors.PrimaryTextColor,
|
||||
PointSize = theme.DefaultFontSize,
|
||||
HAnchor =HAnchor.Stretch,
|
||||
VAnchor = VAnchor.Stretch
|
||||
HAnchor = HAnchor.Left | HAnchor.Fit,
|
||||
VAnchor = VAnchor.Top | VAnchor.Fit,
|
||||
Margin = new BorderDouble(left: 30, top: 2)
|
||||
};
|
||||
treeView.AfterSelect += (s, e) =>
|
||||
{
|
||||
|
|
@ -207,7 +198,13 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
}
|
||||
selectedObjectPanel.SetActiveItem((IObject3D)treeView.SelectedNode.Tag);
|
||||
};
|
||||
treeSection.AddChild(treeView);
|
||||
|
||||
var treeSection = new ResizableSectionWidget("Design History".Localize(), sceneContext.ViewState.SceneTreeHeight, treeView, theme, expanded: false);
|
||||
treeSection.Resized += (s, e) =>
|
||||
{
|
||||
sceneContext.ViewState.SceneTreeHeight = treeSection.ResizeContainer.Height;
|
||||
};
|
||||
modelViewSidePanel.AddChild(treeSection);
|
||||
|
||||
modelViewSidePanel.AddChild(selectedObjectPanel);
|
||||
splitContainer.AddChild(modelViewSidePanel);
|
||||
|
|
@ -361,8 +358,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
public override void OnClosed(ClosedEventArgs e)
|
||||
{
|
||||
sceneContext.ViewState.SceneTreeHeight = treeSection.Height;
|
||||
|
||||
viewControls3D.TransformStateChanged -= ViewControls3D_TransformStateChanged;
|
||||
Scene.SelectionChanged -= Scene_SelectionChanged;
|
||||
this.InteractionLayer.DrawGlOpaqueContent -= Draw_GlOpaqueContent;
|
||||
|
|
@ -1280,7 +1275,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
protected bool allowAutoRotate = false;
|
||||
|
||||
public MeshViewerWidget meshViewerWidget;
|
||||
private BottomResizeContainer treeSection;
|
||||
private bool assigningTreeNode;
|
||||
|
||||
public InteractiveScene Scene => sceneContext.Scene;
|
||||
|
|
|
|||
|
|
@ -596,6 +596,19 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
});
|
||||
}
|
||||
},
|
||||
#if DEBUG
|
||||
new NamedAction()
|
||||
{
|
||||
Title = "GC.Collect".Localize(),
|
||||
Action = () =>
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
GC.Collect();
|
||||
});
|
||||
}
|
||||
},
|
||||
#endif
|
||||
new NamedAction() { Title = "----" },
|
||||
new NamedAction()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -530,9 +530,18 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
|
||||
private UIField CreateToggleFieldForSection(SliceSettingData settingData)
|
||||
{
|
||||
// Create toggle field for key
|
||||
UIField uiField = new ToggleboxField(theme);
|
||||
bool useDefaultSavePattern = false;
|
||||
|
||||
string sliceSettingValue = settingsContext.GetValue(settingData.SlicerConfigName);
|
||||
|
||||
// Create toggle field for key
|
||||
UIField uiField = new ToggleboxField(theme)
|
||||
{
|
||||
HelpText = settingData.HelpText,
|
||||
Name = $"{settingData.PresentationName} Field"
|
||||
};
|
||||
uiField.Initialize(tabIndexForItem++);
|
||||
|
||||
uiField.ValueChanged += (s, e) =>
|
||||
{
|
||||
if (e.UserInitiated)
|
||||
|
|
@ -559,15 +568,9 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
allUiFields[settingData.SlicerConfigName] = uiField;
|
||||
}
|
||||
|
||||
uiField.HelpText = settingData.HelpText;
|
||||
|
||||
uiField.Name = $"{settingData.PresentationName} Field";
|
||||
uiField.Initialize(tabIndexForItem++);
|
||||
|
||||
string sliceSettingValue = settingsContext.GetValue(settingData.SlicerConfigName);
|
||||
|
||||
uiField.SetValue(sliceSettingValue, userInitiated: false);
|
||||
|
||||
// Second ValueChanged listener defined after SetValue to ensure it's unaffected by initial change
|
||||
uiField.ValueChanged += (s, e) =>
|
||||
{
|
||||
if (useDefaultSavePattern
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue