Made the cache cleaning also delete unused directories.

Made the text creator scroll bars sized better.
This commit is contained in:
Lars Brubaker 2015-02-21 10:09:39 -08:00
parent 5bc8795d86
commit c166af5795
5 changed files with 54 additions and 12 deletions

View file

@ -370,15 +370,42 @@ namespace MatterHackers.MatterControl
}
}
// Enumerate every file and if it is a mesh file or image file and not in our list, delete it.
foreach (string file in Directory.EnumerateFiles(userDataPath, "*.*", SearchOption.AllDirectories))
// If the count is less than 0 then we have never run and we need to populate the library and queue still. So don't delete anything yet.
if (referencedPrintItemsFilePaths.Count > 0)
{
CleanDirectory(userDataPath, referencedPrintItemsFilePaths, referencedThumbnailFiles);
}
}
static int CleanDirectory(string path, HashSet<string> referencedPrintItemsFilePaths, HashSet<string> referencedThumbnailFiles)
{
int contentCount = 0;
foreach (string directory in Directory.EnumerateDirectories(path))
{
int directoryContentCount = CleanDirectory(directory, referencedPrintItemsFilePaths, referencedThumbnailFiles);
if (directoryContentCount == 0)
{
Directory.Delete(directory);
}
else
{
// it has a directory that has content
contentCount++;
}
}
foreach (string file in Directory.EnumerateFiles(path, "*.*"))
{
switch (Path.GetExtension(file).ToUpper())
{
case ".STL":
case ".AMF":
case ".GCODE":
if (!referencedPrintItemsFilePaths.Contains(file))
if (referencedPrintItemsFilePaths.Contains(file))
{
contentCount++;
}
else
{
File.Delete(file);
}
@ -386,7 +413,11 @@ namespace MatterHackers.MatterControl
case ".PNG":
case ".TGA":
if (!referencedThumbnailFiles.Contains(file))
if (referencedThumbnailFiles.Contains(file))
{
contentCount++;
}
else
{
File.Delete(file);
}
@ -394,11 +425,17 @@ namespace MatterHackers.MatterControl
case ".JSON":
// may want to clean these up eventually
contentCount++; // if we delete these we should not incement this
break;
default:
// we have something in the directory that we are not going to delete
contentCount++;
break;
}
}
// We could also clean up any empty directories.
return contentCount;
}
#if false // kevin code 2014 04 22

View file

@ -58,8 +58,7 @@ namespace MatterHackers.MatterControl
public abstract void AddElements();
public abstract void HideTopContainer();
public abstract void ToggleTopContainer();
public abstract void ToggleTopContainer();
}
public class CompactApplicationView : ApplicationView
@ -153,10 +152,8 @@ namespace MatterHackers.MatterControl
public TopContainerWidget()
: base(FlowDirection.TopToBottom)
{
}
public void SetOriginalHeight()
{
originalHeight = this.Height;

View file

@ -130,8 +130,13 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
protected static SolidSlider InsertUiForSlider(FlowLayoutWidget wordOptionContainer, string header, double min = 0, double max = .5)
{
double scrollBarWidth = 10;
TextWidget spacingText = new TextWidget(header, textColor: ActiveTheme.Instance.PrimaryTextColor);
double scrollBarWidth = 10;
if (ActiveTheme.Instance.DisplayMode == ActiveTheme.ApplicationDisplayType.Touchscreen)
{
scrollBarWidth = 20;
}
TextWidget spacingText = new TextWidget(header, textColor: ActiveTheme.Instance.PrimaryTextColor);
spacingText.Margin = new BorderDouble(10, 3, 3, 5);
spacingText.HAnchor = HAnchor.ParentLeft;
wordOptionContainer.AddChild(spacingText);

View file

@ -817,7 +817,7 @@
{
"SlicerConfigName": "start_gcode",
"PresentationName": "Start G-Code",
"HelpText": "This gcode will be inserted into the output right after the temperature setting. If you have the commands to set temperature in this section they will not be generated outside of this section. You can also include values from other settings such as [first_layer_temperature].",
"HelpText": "This gcode will be inserted into the output right after the temperature setting. If you have the commands to set temperature in this section they will not be generated outside of this section. You can also include values from other settings such as [temperature].",
"DataEditType": "MULTI_LINE_TEXT",
"ExtraSettings": ""
},

View file

@ -3122,3 +3122,6 @@ Translated:Heat Before Homing
English:Clear Print History
Translated:Clear Print History
English:This gcode will be inserted into the output right after the temperature setting. If you have the commands to set temperature in this section they will not be generated outside of this section. You can also include values from other settings such as [temperature].
Translated:This gcode will be inserted into the output right after the temperature setting. If you have the commands to set temperature in this section they will not be generated outside of this section. You can also include values from other settings such as [temperature].