Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Source Code for: Util - View O2.Platform.Scripts file length v1.0
var topPanel = "Util - View O2.Platform.Scripts file length".popupWindow(1000,500).insert_LogViewer();
//var topPanel = panel.add_Panel(true);
var targetFolder = PublicDI.config.LocalScriptsFolder;;
List<string> allFiles = null;
var treeView = topPanel.add_TreeView();
var slider = treeView.insert_Above(20)
.add_Slider();
var label = slider.insert_Right(180).add_Label("",5).font_bold().text_Center().autoSize();
var textBox = topPanel.insert_Above(20).add_Label("Target Folder",3).append_TextBox(targetFolder).align_Right();
Action<int> showFiles =
(depth)=>
{
"Showing files with size bigger than {0}".info(depth);
var files = allFiles.where((file)=>file.size() > depth);
treeView.beginUpdate();
treeView.clear().add_Nodes(files, (file)=>file.remove(targetFolder));
treeView.endUpdate();
label.set_Text("of {0}, {1} files bigger than {2}".format(allFiles.size(),files.size(), depth));
};
Action mapFiles =
()=>{
"finding all files from base folder: {0}".debug(targetFolder);
allFiles = targetFolder.files(true).remove_Containing(".git");
"loaded {0} files from disk (not including .git files)".debug(allFiles.size());
};
Action<string> mapFolder =
(item)=>{
if (item.isFile())
item = item.parentFolder();
if(item.isFolder())
{
targetFolder = item;
textBox.set_Text(targetFolder);
mapFiles();
showFiles(slider.value());
}
else
"Couldn't map folder: {0}".error(item);
};
//topPanel.mainMenu().add_Menu("Actions")
treeView.add_ContextMenu()
.add_MenuItem("For selected file, Open parent folder in Windows Explorer", true,()=> treeView.selected().tag<string>().parentFolder().startProcess())
.add_MenuItem("Reload file list from disk", ()=> mapFiles());
//.add_MenuItem("Download O2.Platform.Scritps", ()=>O2Scripts.downloadO2Scripts());;
treeView.afterSelect<string>((file)=> "File {0} size = {1}".info(file, file.size()));
topPanel.onDrop(mapFolder);
textBox.onDrop(mapFolder);
textBox.onTextChange(mapFolder);
treeView.onDrag<string>();
mapFiles();
slider.maximum(240)
.onValueChanged(showFiles)
.value(120);
//using O2.FluentSharp.REPL
//O2Embed:Utility.ico
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.