private void btnexport_Click(object sender, EventArgs e) { FileSkimmerBackend.GetFile(new[] { ".wid" }, FileOpenerStyle.Save, (path) => { Utils.WriteAllText(path, JsonConvert.SerializeObject(temp_details)); }); }
public DownloadControl(int index) { InitializeComponent(); var d = DownloadManager.Downloads[index]; lbshiftneturl.Text = d.ShiftnetUrl; pcicon.Image = FileSkimmerBackend.GetImage(d.Destination); int bytesTransferred = 0; pgprogress.Maximum = DownloadManager.Downloads[index].Bytes.Length; pgprogress.Value = DownloadManager.Downloads[index].Progress; DownloadManager.ProgressUpdate += (i, p) => { try { this.Invoke(new Action(() => { if (i == index) { bytesTransferred += 256; pgprogress.Value = bytesTransferred; lbshiftneturl.Text = $@"{d.ShiftnetUrl} {bytesTransferred} B out of {d.Bytes.Length} B transferred at {DownloadManager.GetDownloadSpeed()} B per second. To {d.Destination}"; pgprogress.Maximum = d.Bytes.Length; } })); } catch { } }; }
private void lvitems_DoubleClick(object sender, EventArgs e) { if (lvitems.SelectedItems.Count <= 0) { return; } var item = lvitems.SelectedItems[0]; var path = item.Tag as string; if (currentdir == "__system") { ChangeDirectory(path); } else if (DirectoryExists(currentdir + "/" + path)) { ChangeDirectory(currentdir + "/" + path); } else if (FileExists(currentdir + "/" + path)) { FileSkimmerBackend.OpenFile(currentdir + "/" + path); } else if (path == "__..") { ChangeToParent(); } }
private void moveToolStripMenuItem_Click(object sender, EventArgs e) { try { string path = currentdir + "/" + lvitems.SelectedItems[0].Tag.ToString(); if (DirectoryExists(path)) { FileSkimmerBackend.GetFile(new[] { "Directory" }, FileOpenerStyle.Save, (newPath) => { Utils.Move(path, newPath); ResetList(); }); } else if (FileExists(path)) { string[] psplit = path.Split('.'); string ext = psplit[psplit.Length - 1]; FileSkimmerBackend.GetFile(new[] { ext }, FileOpenerStyle.Save, (newPath) => { Utils.Move(path, newPath); ResetList(); }); } } catch { } }
private StackPanel CreateUpOneDirectory() { var sp = new StackPanel(); sp.Margin = new Thickness(5); sp.Width = 50; var label = new TextBlock(); label.Text = "Up one directory"; label.TextWrapping = TextWrapping.Wrap; label.TextAlignment = TextAlignment.Center; var img = new Image(); img.Width = 42; img.Height = 42; img.Source = FileSkimmerBackend.GetImage("__upone").ToBitmapImage(); sp.Children.Add(img); sp.Children.Add(label); sp.PreviewMouseLeftButtonDown += (o, a) => { if (a.ClickCount == 2) { GoUp(); } }; return(sp); }
private void btnimport_Click(object sender, EventArgs e) { FileSkimmerBackend.GetFile(new[] { ".nme" }, FileOpenerStyle.Open, new Action <string>((path) => { names = JsonConvert.DeserializeObject <Dictionary <string, string> >(Utils.ReadAllText(path)); })); }
private void btnexport_Click(object sender, EventArgs e) { FileSkimmerBackend.GetFile(new[] { ".nme" }, FileOpenerStyle.Save, new Action <string>((path) => { Utils.WriteAllText(path, JsonConvert.SerializeObject(names)); })); }
private void saveToolStripMenuItem_Click(object sender, EventArgs e) { var txt = new List <string>(); txt.Add(".rtf"); txt.Add(".txt"); FileSkimmerBackend.GetFile(txt.ToArray(), FileOpenerStyle.Save, (path) => SaveFile(path)); }
private void btnimport_Click(object sender, EventArgs e) { FileSkimmerBackend.GetFile(new[] { ".wid" }, FileOpenerStyle.Open, (path) => { temp_details = JsonConvert.DeserializeObject <Dictionary <string, WidgetDetails> >(Utils.ReadAllText(path)); SetupUI(); }); }
private void btnbrowse_Click(object sender, EventArgs e) { FileSkimmerBackend.GetFile(new[] { ".stp" }, FileOpenerStyle.Open, (file) => { txtfilepath.Text = file; btnstart.Show(); }); }
private void btnscanfile_Click(object sender, EventArgs e) { FileSkimmerBackend.GetFile(new[] { "" }, FileOpenerStyle.Open, (path) => { ScanFile(path); SetupSummary(); }); }
private void btnsendfile_Click(object sender, EventArgs e) { FileSkimmerBackend.GetFile(new[] { "" }, FileOpenerStyle.Open, (file) => { var finf = ShiftOS.Objects.ShiftFS.Utils.GetFileInfo(file); PostMessage($"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}", ChatID, "<user sent a file: " + finf.Name + ">"); FileSent?.Invoke(finf); }); }
private void openBinaryToolStripMenuItem_Click(object sender, EventArgs e) { FileSkimmerBackend.GetFile(new[] { ".svm" }, FileOpenerStyle.Open, new Action <string>((program) => { memory = Utils.ReadAllBytes(program); programCounter = 0; stack = new Stack <int>(); registers = new int[64000]; currentRegister = 0; Start(); })); }
private void addSongToolStripMenuItem_Click(object sender, EventArgs e) { FileSkimmerBackend.GetFile(new[] { ".mp4", ".wmv" }, FileOpenerStyle.Open, (result) => { var finf = ShiftOS.Objects.ShiftFS.Utils.GetFileInfo(result); File.WriteAllBytes(finf.Name, ShiftOS.Objects.ShiftFS.Utils.ReadAllBytes(result)); filePath = finf.Name; wpaudio.URL = filePath; wpaudio.Ctlcontrols.play(); btnplay.Text = "Pause"; }); }
public void ResetList() { if (lvitems.LargeImageList == null) { lvitems.LargeImageList = new ImageList(); lvitems.LargeImageList.TransparentColor = SkinEngine.LoadedSkin.ControlColor; lvitems.LargeImageList.ImageSize = new Size(42, 42); FileSkimmer.GetAllTypes(lvitems.LargeImageList); } lvitems.Items.Clear(); if (currentdir == "__system") { //List all drives foreach (var dir in Mounts) { var item = FileSkimmer.ConstructItemAsMount(dir); item.ImageKey = "Mount"; lvitems.Items.Add(item); } } else if (DirectoryExists(currentdir)) { var up = new ListViewItem(); up.ImageKey = "UpOne"; up.Text = "Up one"; up.Tag = "__.."; lvitems.Items.Add(up); foreach (var dir in GetDirectories(currentdir)) { var item = FileSkimmer.ConstructItem(GetDirectoryInfo(dir)); item.ImageKey = "Directory"; lvitems.Items.Add(item); } foreach (var dir in GetFiles(currentdir)) { if (dir.EndsWith(cbfiletypes.SelectedItem as string)) { var item = FileSkimmer.ConstructItem(GetFileInfo(dir)); item.ImageKey = FileSkimmerBackend.GetFileType(dir).ToString(); lvitems.Items.Add(item); } } } }
private void addSongToolStripMenuItem_Click(object sender, EventArgs e) { FileSkimmerBackend.GetFile(new[] { ".mp3", ".wav" }, FileOpenerStyle.Open, (path) => { if (!lbtracks.Items.Contains(path)) { lbtracks.Items.Add(path); } else { Infobox.Show("Song already added!", "That song is already added to the Audio Player playlist."); } }); }
private void btnopen_Click(object sender, RoutedEventArgs e) { string filters = ".txt"; if (Shiftorium.UpgradeInstalled("textpad_lua_support")) { filters += ";.lua"; } if (Shiftorium.UpgradeInstalled("textpad_python_support")) { filters += ";.py"; } FileSkimmerBackend.GetFile(filters.Split(';'), FileOpenerStyle.Open, new Action <string>((file) => LoadFile(file))); }
private void lnkdownload_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { var attrib = typeof(Applications.WidgetManagerFrontend).GetCustomAttributes(false).FirstOrDefault(x => x is StpContents) as StpContents; if (attrib != null) { FileSkimmerBackend.GetFile(new[] { ".stp" }, FileOpenerStyle.Save, (file) => { WriteAllText(file, JsonConvert.SerializeObject(attrib)); }); } else { Infobox.Show("Service not available.", "The Shiftnet service you requested is not available."); } }
public static void InitiateEngine(System.IO.TextWriter writer) { OutOfBoxExperience.Init(new OOBE()); AppearanceManager.Initiate(new WpfWindowManager()); Infobox.Init(new WpfInfoboxFrontend()); FileSkimmerBackend.Init(new Applications.WpfFSFrontend()); if (writer != null) { Console.SetOut(writer); } SaveSystem.Begin(false); AppearanceManager.OnExit += () => { Environment.Exit(0); }; }
public static void DevXProgressReport() { Applications.Chat chat = null; Desktop.InvokeOnWorkerThread(() => { chat = OpenChat(); }); while (chat == null) { Thread.Sleep(10); } CurrentChat = chat; chat.ChatID = "devx@system"; chat.ShowChat(); SendChatMessage("devx", "Greetings, " + SaveSystem.CurrentUser.Username); SendChatMessage("devx", "I guess it is time to assess your system."); SendChatMessage("devx", "After all, you've gotten " + SaveSystem.CurrentSave.CountUpgrades() + " Shiftorium Upgrades since I've last contacted you."); SendChatMessage("devx", "And you have a Codepoint balance of " + SaveSystem.CurrentSave.Codepoints + "."); SendChatMessage("devx", "And...oh wait... what!? You found the... How did you find the Shiftnet!?"); SendChatMessage("devx", "Naughty, naughty user. You're not supposed to be on there."); SendChatMessage("devx", "Whatever. I've got a task for you."); SendChatMessage("devx", "Your logs show me you're in contact with Maureen Fenn."); SendChatMessage("devx", "I have a document to send her. You're my messanger."); SendChatMessage("devx", "Though, like any good messanger, I urge you not to open it."); SendChatMessage("devx", "<sent a file: unknown>"); SendChatMessage("devx", "When you get it, just send it to her. Do not delete it."); bool fileWritten = false; Desktop.InvokeOnWorkerThread(() => { FileSkimmerBackend.GetFile(new[] { ".rtf" }, FileOpenerStyle.Save, (loc) => { var bytes = Convert.FromBase64String(Properties.Resources.DevXMaureenLetter); Objects.ShiftFS.Utils.WriteAllBytes(loc, bytes); fileWritten = true; }); }); while (fileWritten == false) { Thread.Sleep(10); } }
private void pinnedItems_Click(object sender, EventArgs e) { try { if (pinnedItems.SelectedNode != null) { string path = pinnedItems.SelectedNode.Tag.ToString(); if (DirectoryExists(path)) { currentdir = path; ResetList(); } else if (FileExists(path)) { FileSkimmerBackend.OpenFile(path); } } } catch { } }
public static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //if ANYONE puts code before those two winforms config lines they will be declared a drunky. - Michael SkinEngine.SetPostProcessor(new DitheringSkinPostProcessor()); LoginManager.Init(new GUILoginFrontend()); CrashHandler.SetGameMetadata(Assembly.GetExecutingAssembly()); SkinEngine.SetIconProber(new ShiftOSIconProvider()); TerminalBackend.TerminalRequested += () => { AppearanceManager.SetupWindow(new Applications.Terminal()); }; Localization.RegisterProvider(new WFLanguageProvider()); Infobox.Init(new Dialog()); LoginManager.Init(new WinForms.GUILoginFrontend()); FileSkimmerBackend.Init(new WinformsFSFrontend()); var desk = new WinformsDesktop(); Desktop.Init(desk); OutOfBoxExperience.Init(new Oobe()); AppearanceManager.Initiate(new WinformsWindowManager()); #if OLD SaveSystem.PreDigitalSocietyConnection += () => { Action completed = null; completed = () => { SaveSystem.Ready.Set(); Engine.AudioManager.PlayCompleted -= completed; AudioManager.StartAmbientLoop(); }; Engine.AudioManager.PlayCompleted += completed; Engine.AudioManager.PlayStream(Properties.Resources.dial_up_modem_02); }; Application.Run(desk); #else Application.Run(new MainMenu.MainMenu(desk)); #endif }
static void Main() { Localization.RegisterProvider(new WFLanguageProvider()); Shiftorium.RegisterProvider(new WinformsShiftoriumProvider()); AppearanceManager.OnExit += () => { Environment.Exit(0); }; TerminalBackend.TerminalRequested += () => { AppearanceManager.SetupWindow(new Applications.Terminal()); }; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); AppearanceManager.Initiate(new WinformsWindowManager()); OutOfBoxExperience.Init(new Oobe()); Infobox.Init(new WinformsInfobox()); FileSkimmerBackend.Init(new WinformsFSFrontend()); var desk = new WinformsDesktop(); Desktop.Init(desk); Application.Run(desk); }
public static FileType GetFileType(string path) { return(FileSkimmerBackend.GetFileType(path)); }
public void Reset() { if (currentFolder != "__system") { this.SetTitle("File Skimmer - " + currentFolder); } else { this.SetTitle("File Skimmer"); } lbfiles.Children.Clear(); if (currentFolder == "__system") { foreach (var dir in Utils.Mounts) { var sp = new StackPanel(); sp.Width = 50; sp.Margin = new Thickness(5); var label = new TextBlock(); label.Text = dir.Name; label.TextWrapping = TextWrapping.Wrap; label.TextAlignment = TextAlignment.Center; var img = new Image(); img.Width = 42; img.Height = 42; img.Source = FileSkimmerBackend.GetImage(Utils.Mounts.IndexOf(dir) + ":").ToBitmapImage(); sp.Children.Add(img); sp.Children.Add(label); sp.PreviewMouseLeftButtonDown += (o, a) => { if (a.ClickCount == 2) { ChangeDirectory(Utils.Mounts.IndexOf(dir) + ":"); } }; lbfiles.Children.Add(sp); } } else { var __up = CreateUpOneDirectory(); lbfiles.Children.Add(__up); foreach (var dir in Utils.GetDirectories(currentFolder)) { var sp = new StackPanel(); sp.Margin = new Thickness(5); sp.Width = 50; var label = new TextBlock(); label.Text = Utils.GetDirectoryInfo(dir).Name; label.TextWrapping = TextWrapping.Wrap; label.TextAlignment = TextAlignment.Center; var img = new Image(); img.Width = 42; img.Height = 42; img.Source = FileSkimmerBackend.GetImage(dir).ToBitmapImage(); sp.Children.Add(img); sp.Children.Add(label); sp.PreviewMouseLeftButtonDown += (o, a) => { if (a.ClickCount == 2) { ChangeDirectory(dir); } }; lbfiles.Children.Add(sp); } foreach (var dir in Utils.GetFiles(currentFolder)) { if (dir.EndsWith(filter.SelectedItem.ToString())) { var sp = new StackPanel(); sp.Margin = new Thickness(5); sp.Width = 50; var label = new TextBlock(); label.Text = Utils.GetFileInfo(dir).Name; label.TextWrapping = TextWrapping.Wrap; label.TextAlignment = TextAlignment.Center; var img = new Image(); img.Width = 42; img.Height = 42; img.Source = FileSkimmerBackend.GetImage(dir).ToBitmapImage(); sp.Children.Add(img); sp.Children.Add(label); sp.PreviewMouseLeftButtonDown += (o, a) => { if (a.ClickCount == 2) { if (OpenerStyle == FileOpenerStyle.Open) { Callback?.Invoke(dir); AppearanceManager.Close(this); } } else { txtfilename.Text = Utils.GetFileInfo(dir).Name; } }; lbfiles.Children.Add(sp); } } } }
public void ResetList() { pinnedItems.Nodes.Clear(); List <string> Pinned = new List <string>(); if (FileExists(Paths.GetPath("data") + "/pinned_items.dat")) { Pinned = JsonConvert.DeserializeObject <List <string> >(ReadAllText(Paths.GetPath("data") + "/pinned_items.dat")); } var node = new TreeNode(); node.Text = "Pinned"; PopulatePinned(node, Pinned.ToArray()); pinnedItems.Nodes.Add(node); node.ExpandAll(); if (lvitems.LargeImageList == null) { lvitems.LargeImageList = new ImageList(); lvitems.LargeImageList.TransparentColor = SkinEngine.LoadedSkin.ControlColor; lvitems.LargeImageList.ImageSize = new Size(42, 42); GetAllTypes(lvitems.LargeImageList); } lvitems.Items.Clear(); if (currentdir == "__system") { //List all drives foreach (var dir in Mounts) { var item = ConstructItemAsMount(dir); item.ImageKey = "Mount"; lvitems.Items.Add(item); } } else if (DirectoryExists(currentdir)) { var up = new ListViewItem(); up.Text = "Up one"; up.ImageKey = "UpOne"; up.Tag = "__.."; lvitems.Items.Add(up); foreach (var dir in GetDirectories(currentdir)) { var item = ConstructItem(GetDirectoryInfo(dir)); item.ImageKey = "Directory"; lvitems.Items.Add(item); } foreach (var dir in GetFiles(currentdir)) { var item = ConstructItem(GetFileInfo(dir)); item.ImageKey = FileSkimmerBackend.GetFileType(dir).ToString(); lvitems.Items.Add(item); } } }
/// <summary> /// Opens a File Skimmer "Save File" dialog. /// </summary> /// <param name="extensions">Semicolon-separated list of file extensions that the opener should let through the filter.</param> /// <param name="callback">Function to be called when the user chooses a file. The string value is the file's path.</param> public void saveFile(string extensions, Action <string> callback) { FileSkimmerBackend.GetFile(extensions.Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries), FileOpenerStyle.Save, callback); }
static FileSkimmer() { FileSkimmerBackend.Init(new WpfFSFrontend()); }
public void OpenFile(string path) { try { switch (FileSkimmerBackend.GetFileType(path)) { case FileType.TextFile: if (!Shiftorium.UpgradeInstalled("textpad")) { throw new Exception(); } var txt = new TextPad(); AppearanceManager.SetupWindow(txt); txt.LoadFile(path); break; case FileType.Executable: //NYI throw new Exception(); case FileType.Lua: try { var runner = new Engine.Scripting.LuaInterpreter(); runner.ExecuteFile(path); } catch (Exception ex) { Infobox.Show("{LUA_ERROR}", ex.Message); } break; case FileType.JSON: //NYI throw new Exception(); case FileType.Filesystem: MountPersistent(path); //If this doesn't fail... FileSkimmerBackend.OpenDirectory((Mounts.Count - 1).ToString() + ":"); break; case FileType.Skin: if (!Shiftorium.UpgradeInstalled("skinning")) { throw new Exception(); } var sl = new Skin_Loader(); AppearanceManager.SetupWindow(sl); sl.LoadedSkin = JsonConvert.DeserializeObject <Skin>(ReadAllText(path)); sl.SetupUI(); break; case FileType.Image: if (!Shiftorium.UpgradeInstalled("artpad_open")) { throw new Exception(); } var ap = new Artpad(); AppearanceManager.SetupWindow(ap); ap.LoadPicture(path); break; default: throw new Exception(); } } catch { Infobox.Show("{NO_APP_TO_OPEN}", "{NO_APP_TO_OPEN_EXP}"); } }
public Image GetImage(string path) { return(Applications.FileSkimmer.GetImage(FileSkimmerBackend.GetFileType(path))); }