continuous

Open full view…

Feature Request: Start & save new project to other sources

seankilleen
Sat, 14 Jul 2018 13:40:13 GMT

I love the idea and potential of Continuous. One thing that is making it a little difficult for me to use it more often is that while I can use continuos as a notepad to tinker with things, I can’t by default save the code anywhere else offered by my iPad (Dropbox, OneDrive, etc.). I know there are ways to extract these files, etc. but i think it would be fantastic to add non-local modes of storage as a user friendly option. This would skyrocket my use of continuous on the go, because I could start an F# scratch pad, build a domain model on my iPad, and then know that I could easily get to those files when I opened my laptop later. I know that continuous may make some assumptions (e.g. code exists within the continuous world, so you’re not going to want to save of all mono etc to the HDD). But a small disclaimer along these lines and the ability to just edit those source files would be fantastic.

memsom
Tue, 17 Jul 2018 12:55:00 GMT

Okay, not tested this on the current release (it worked though, as I used it to transfer files on mass), but try this in a new script file in the root of the Continuous file system. Change the final line to change the files you are zipping - it runs on Windows under DotNet Core 2.1. Write a UI to make it easier if you're feeling industrious (I was going to, but never got round to it.): using System; using System.IO; using System.IO.Compression; static class SimpleZip { static ZipArchive CreateZipArchive(string filename, FileMode mode = FileMode.CreateNew, FileAccess access = FileAccess.Write, FileShare share = FileShare.None) { var fs = new FileStream(filename, mode, access, share, bufferSize: 0x1000, useAsync: false); var archive = default(ZipArchive); //could also be ZipArchive archive = null; try { archive = new ZipArchive(fs, ZipArchiveMode.Create, leaveOpen: false, entryNameEncoding: null); } catch (System.Exception) { fs.Dispose(); } return archive; } public static void ZipDirectory(string path, string name, bool deleteExisting = true) { if (deleteExisting && File.Exists(name)) { File.Delete(name); } using (var archive = CreateZipArchive(name)) { var files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories); foreach (var file in files) { AddFile(archive, file); } } } static void AddFile(ZipArchive archive, string file) { using (var fs = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize: 0x1000, useAsync: false)) { var entry = archive.CreateEntry(file, CompressionLevel.Optimal); entry.LastWriteTime = DateTimeOffset.Now; using (var es = entry.Open()) { fs.CopyTo(es); } } } } SimpleZip.ZipDirectory("Examples", "Examples.zip");

memsom
Tue, 17 Jul 2018 12:56:22 GMT

Sorry, the formatting was b0rked by the forum software.

memsom
Tue, 17 Jul 2018 16:11:13 GMT

Okay - this has a simple UI, though it's not really very well tested, so YMMV. Scroll through the list of directories, pick the one you want and click "zip". You should get a zip file in the root of your filesystem, and then you should be able to share that file. I was looking at getting Xamarin.Essentials to open a share sheet, but as far as I could tell, it seem to only do text at the moment. ----------------------------------------- using System; using System.IO; using System.IO.Compression; using Xamarin.Forms; using System.Collections.ObjectModel; using System.Linq; public static class SimpleZip { static ZipArchive CreateZipArchive(string filename, FileMode mode = FileMode.CreateNew, FileAccess access = FileAccess.Write, FileShare share = FileShare.None) { var fs = new FileStream(filename, mode, access, share, bufferSize: 0x1000, useAsync: false); var archive = default(ZipArchive); try { archive = new ZipArchive(fs, ZipArchiveMode.Create, leaveOpen: false, entryNameEncoding: null); } catch (System.Exception) { fs.Dispose(); } return archive; } public static void ZipDirectory(string path, string name, bool deleteExisting = true) { if (deleteExisting && File.Exists(name)) { File.Delete(name); } using (var archive = CreateZipArchive(name)) { var files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories); foreach (var file in files) { AddFile(archive, file); } } } static void AddFile(ZipArchive archive, string file) { using (var fs = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize: 0x1000, useAsync: false)) { var entry = archive.CreateEntry(file, CompressionLevel.Optimal); entry.LastWriteTime = DateTimeOffset.Now; using (var es = entry.Open()) { fs.CopyTo(es); } } } } public class PathItem { public string Path { get; set; } } public class MainPage : ContentPage { string selected = string.Empty; public MainPage() { var directories = Directory.GetDirectories(".", "*.*", SearchOption.AllDirectories)?.Select(s => new PathItem { Path = s.Remove(0, 2), }).ToList(); //this is probably not the best var zipButton = new Button { Text = "Zip", VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, FontSize = 25, BorderWidth = 1, }; zipButton.Clicked += (s, e) => { if (!string.IsNullOrEmpty(selected)) { var file = Path.ChangeExtension(Path.GetFileName(selected), ".zip"); SimpleZip.ZipDirectory(selected, file); } }; var lsize = Device.GetNamedSize( NamedSize.Medium, typeof(Label) ); var lColor = Color.CadetBlue; var directoryListView = new ListView { ItemsSource = directories, ItemTemplate = new DataTemplate(() => { var pathLabel = new Label { FontSize = lsize, TextColor = lColor, }; pathLabel.SetBinding( Label.TextProperty, new Binding("Path", BindingMode.OneWay) ); var result = new ViewCell { View = new StackLayout { Padding = new Thickness(0, 5), Spacing = 0, Orientation = StackOrientation.Horizontal, Children = { pathLabel } } }; return result; }) }; directoryListView.BackgroundColor = Color.Beige; directoryListView.HasUnevenRows = true; directoryListView.ItemSelected += (s, e) => { var selected = (PathItem)directoryListView.SelectedItem; try { this.selected = selected.Path; } catch (Exception) { } Console.WriteLine(this.selected); }; Content = new StackLayout { Padding = new Thickness(25), Orientation = StackOrientation.Vertical, Children = { new StackLayout { Padding = new Thickness(50, 0), Orientation = StackOrientation.Vertical, Children = { directoryListView, zipButton } } } }; } } public class App : Application { public App() { MainPage = new MainPage(); } } var app = new App(); ​