diff options
| author | william341 <[email protected]> | 2017-06-29 13:13:45 -0700 |
|---|---|---|
| committer | william341 <[email protected]> | 2017-06-29 13:13:45 -0700 |
| commit | ad387c41e7d6cc547431e88695d4723ea2dba913 (patch) | |
| tree | a68282dda40c4f0b28883241c7adcf9010f4550e /ShiftOS.MFSProfiler | |
| parent | b4b19e7a4d203b58537f5b98214296ab52c49b2d (diff) | |
| parent | 5bebd4411bc6266cbee482a429ba794eefa8f9b6 (diff) | |
| download | shiftos_thereturn-ad387c41e7d6cc547431e88695d4723ea2dba913.tar.gz shiftos_thereturn-ad387c41e7d6cc547431e88695d4723ea2dba913.tar.bz2 shiftos_thereturn-ad387c41e7d6cc547431e88695d4723ea2dba913.zip | |
Merge remote-tracking branch 'refs/remotes/shiftos-game/master'
Diffstat (limited to 'ShiftOS.MFSProfiler')
| -rw-r--r-- | ShiftOS.MFSProfiler/Infobox.Designer.cs | 169 | ||||
| -rw-r--r-- | ShiftOS.MFSProfiler/Infobox.cs | 87 | ||||
| -rw-r--r-- | ShiftOS.MFSProfiler/Infobox.resx | 120 | ||||
| -rw-r--r-- | ShiftOS.MFSProfiler/Main.Designer.cs | 45 | ||||
| -rw-r--r-- | ShiftOS.MFSProfiler/Main.cs | 96 | ||||
| -rw-r--r-- | ShiftOS.MFSProfiler/ShiftOS.MFSProfiler.csproj | 9 |
6 files changed, 520 insertions, 6 deletions
diff --git a/ShiftOS.MFSProfiler/Infobox.Designer.cs b/ShiftOS.MFSProfiler/Infobox.Designer.cs new file mode 100644 index 0000000..2726ebb --- /dev/null +++ b/ShiftOS.MFSProfiler/Infobox.Designer.cs @@ -0,0 +1,169 @@ +namespace ShiftOS.MFSProfiler +{ + partial class Infobox + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.panel1 = new System.Windows.Forms.Panel(); + this.txtinput = new System.Windows.Forms.TextBox(); + this.lbmessage = new System.Windows.Forms.Label(); + this.flyesno = new System.Windows.Forms.FlowLayoutPanel(); + this.btnyes = new System.Windows.Forms.Button(); + this.btnno = new System.Windows.Forms.Button(); + this.btnok = new System.Windows.Forms.Button(); + this.pbicon = new System.Windows.Forms.PictureBox(); + this.panel1.SuspendLayout(); + this.flyesno.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pbicon)).BeginInit(); + this.SuspendLayout(); + // + // panel1 + // + this.panel1.Controls.Add(this.txtinput); + this.panel1.Controls.Add(this.lbmessage); + this.panel1.Controls.Add(this.flyesno); + this.panel1.Controls.Add(this.btnok); + this.panel1.Controls.Add(this.pbicon); + this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel1.Location = new System.Drawing.Point(0, 0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(325, 138); + this.panel1.TabIndex = 0; + // + // txtinput + // + this.txtinput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtinput.Location = new System.Drawing.Point(88, 77); + this.txtinput.Name = "txtinput"; + this.txtinput.Size = new System.Drawing.Size(234, 20); + this.txtinput.TabIndex = 4; + // + // lbmessage + // + this.lbmessage.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.lbmessage.Location = new System.Drawing.Point(85, 19); + this.lbmessage.Name = "lbmessage"; + this.lbmessage.Size = new System.Drawing.Size(237, 55); + this.lbmessage.TabIndex = 3; + this.lbmessage.Text = "label1"; + this.lbmessage.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // flyesno + // + this.flyesno.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.flyesno.AutoSize = true; + this.flyesno.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.flyesno.Controls.Add(this.btnyes); + this.flyesno.Controls.Add(this.btnno); + this.flyesno.Location = new System.Drawing.Point(129, 95); + this.flyesno.Name = "flyesno"; + this.flyesno.Size = new System.Drawing.Size(78, 29); + this.flyesno.TabIndex = 2; + this.flyesno.WrapContents = false; + // + // btnyes + // + this.btnyes.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.btnyes.AutoSize = true; + this.btnyes.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnyes.Location = new System.Drawing.Point(3, 3); + this.btnyes.Name = "btnyes"; + this.btnyes.Size = new System.Drawing.Size(35, 23); + this.btnyes.TabIndex = 4; + this.btnyes.Text = "Yes"; + this.btnyes.UseVisualStyleBackColor = true; + this.btnyes.Click += new System.EventHandler(this.btnyes_Click); + // + // btnno + // + this.btnno.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.btnno.AutoSize = true; + this.btnno.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnno.Location = new System.Drawing.Point(44, 3); + this.btnno.Name = "btnno"; + this.btnno.Size = new System.Drawing.Size(31, 23); + this.btnno.TabIndex = 3; + this.btnno.Text = "No"; + this.btnno.UseVisualStyleBackColor = true; + this.btnno.Click += new System.EventHandler(this.btnno_Click); + // + // btnok + // + this.btnok.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.btnok.AutoSize = true; + this.btnok.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnok.Location = new System.Drawing.Point(149, 101); + this.btnok.Name = "btnok"; + this.btnok.Size = new System.Drawing.Size(32, 23); + this.btnok.TabIndex = 1; + this.btnok.Text = "OK"; + this.btnok.UseVisualStyleBackColor = true; + this.btnok.Click += new System.EventHandler(this.btnok_Click); + // + // pbicon + // + this.pbicon.Location = new System.Drawing.Point(14, 19); + this.pbicon.Name = "pbicon"; + this.pbicon.Size = new System.Drawing.Size(64, 64); + this.pbicon.TabIndex = 0; + this.pbicon.TabStop = false; + // + // Infobox + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(325, 138); + this.Controls.Add(this.panel1); + this.Name = "Infobox"; + this.panel1.ResumeLayout(false); + this.panel1.PerformLayout(); + this.flyesno.ResumeLayout(false); + this.flyesno.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pbicon)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Label lbmessage; + private System.Windows.Forms.FlowLayoutPanel flyesno; + private System.Windows.Forms.Button btnyes; + private System.Windows.Forms.Button btnno; + private System.Windows.Forms.Button btnok; + private System.Windows.Forms.PictureBox pbicon; + private System.Windows.Forms.TextBox txtinput; + } +}
\ No newline at end of file diff --git a/ShiftOS.MFSProfiler/Infobox.cs b/ShiftOS.MFSProfiler/Infobox.cs new file mode 100644 index 0000000..a30ac5a --- /dev/null +++ b/ShiftOS.MFSProfiler/Infobox.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ShiftOS.MFSProfiler +{ + public partial class Infobox : Form + { + public Infobox() + { + InitializeComponent(); + } + + public Action<string> TextCallback = null; + public Action<bool> YesNoCallback = null; + + public string MessageText + { + get + { + return lbmessage.Text; + } + set + { + lbmessage.Text = value; + } + } + + public bool ShowText + { + get { return txtinput.Visible; } + set { txtinput.Visible = value; } + } + + public bool ShowYesNo + { + get { return btnyes.Parent.Visible; } + set { btnyes.Parent.Visible = value; } + } + + public static void PromptYesNo(string title, string message, Action<bool> callback) + { + var inf = new Infobox(); + inf.ShowText = false; + inf.ShowYesNo = true; + inf.Text = title; + inf.MessageText = message; + inf.YesNoCallback = callback; + inf.ShowDialog(); + } + + public static void PromptText(string title, string message, Action<string> callback) + { + var inf = new Infobox(); + inf.ShowYesNo = false; + inf.ShowText = true; + inf.Text = title; + inf.MessageText = message; + inf.TextCallback = callback; + inf.ShowDialog(); + } + + private void btnyes_Click(object sender, EventArgs e) + { + YesNoCallback?.Invoke(true); + this.Close(); + } + + private void btnno_Click(object sender, EventArgs e) + { + YesNoCallback?.Invoke(false); + this.Close(); + } + + private void btnok_Click(object sender, EventArgs e) + { + TextCallback?.Invoke(txtinput.Text); + this.Close(); + } + } +} diff --git a/ShiftOS.MFSProfiler/Infobox.resx b/ShiftOS.MFSProfiler/Infobox.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.MFSProfiler/Infobox.resx @@ -0,0 +1,120 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root>
\ No newline at end of file diff --git a/ShiftOS.MFSProfiler/Main.Designer.cs b/ShiftOS.MFSProfiler/Main.Designer.cs index 83e9b72..d97c5b9 100644 --- a/ShiftOS.MFSProfiler/Main.Designer.cs +++ b/ShiftOS.MFSProfiler/Main.Designer.cs @@ -56,6 +56,7 @@ namespace ShiftOS.MFSProfiler this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.tvfiles = new System.Windows.Forms.TreeView(); this.panel1 = new System.Windows.Forms.Panel(); + this.button2 = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button(); this.pnlfileinfo = new System.Windows.Forms.Panel(); this.groupBox2 = new System.Windows.Forms.GroupBox(); @@ -71,6 +72,8 @@ namespace ShiftOS.MFSProfiler this.newFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.newDirectoryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.exportToMFSFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.button3 = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); @@ -115,6 +118,8 @@ namespace ShiftOS.MFSProfiler // // panel1 // + this.panel1.Controls.Add(this.button3); + this.panel1.Controls.Add(this.button2); this.panel1.Controls.Add(this.button1); this.panel1.Dock = System.Windows.Forms.DockStyle.Top; this.panel1.Location = new System.Drawing.Point(0, 0); @@ -122,6 +127,16 @@ namespace ShiftOS.MFSProfiler this.panel1.Size = new System.Drawing.Size(246, 30); this.panel1.TabIndex = 1; // + // button2 + // + this.button2.Location = new System.Drawing.Point(86, 4); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(75, 23); + this.button2.TabIndex = 1; + this.button2.Text = "Create New"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // // button1 // this.button1.Location = new System.Drawing.Point(4, 4); @@ -237,14 +252,15 @@ namespace ShiftOS.MFSProfiler this.ctxfileoptions.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.newFileToolStripMenuItem, this.newDirectoryToolStripMenuItem, - this.deleteToolStripMenuItem}); + this.deleteToolStripMenuItem, + this.exportToMFSFileToolStripMenuItem}); this.ctxfileoptions.Name = "ctxfileoptions"; - this.ctxfileoptions.Size = new System.Drawing.Size(153, 92); + this.ctxfileoptions.Size = new System.Drawing.Size(171, 92); // // newFileToolStripMenuItem // this.newFileToolStripMenuItem.Name = "newFileToolStripMenuItem"; - this.newFileToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.newFileToolStripMenuItem.Size = new System.Drawing.Size(148, 22); this.newFileToolStripMenuItem.Text = "New file"; this.newFileToolStripMenuItem.Click += new System.EventHandler(this.newFileToolStripMenuItem_Click); // @@ -253,13 +269,31 @@ namespace ShiftOS.MFSProfiler this.newDirectoryToolStripMenuItem.Name = "newDirectoryToolStripMenuItem"; this.newDirectoryToolStripMenuItem.Size = new System.Drawing.Size(152, 22); this.newDirectoryToolStripMenuItem.Text = "New directory"; + this.newDirectoryToolStripMenuItem.Click += new System.EventHandler(this.newDirectoryToolStripMenuItem_Click); // // deleteToolStripMenuItem // this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem"; - this.deleteToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.deleteToolStripMenuItem.Size = new System.Drawing.Size(148, 22); this.deleteToolStripMenuItem.Text = "Delete"; // + // exportToMFSFileToolStripMenuItem + // + this.exportToMFSFileToolStripMenuItem.Name = "exportToMFSFileToolStripMenuItem"; + this.exportToMFSFileToolStripMenuItem.Size = new System.Drawing.Size(170, 22); + this.exportToMFSFileToolStripMenuItem.Text = "Export To MFS File"; + this.exportToMFSFileToolStripMenuItem.Click += new System.EventHandler(this.exportToMFSFileToolStripMenuItem_Click); + // + // button3 + // + this.button3.Location = new System.Drawing.Point(167, 3); + this.button3.Name = "button3"; + this.button3.Size = new System.Drawing.Size(75, 23); + this.button3.TabIndex = 2; + this.button3.Text = "From Dir"; + this.button3.UseVisualStyleBackColor = true; + this.button3.Click += new System.EventHandler(this.button3_Click); + // // Main // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -306,6 +340,9 @@ namespace ShiftOS.MFSProfiler private System.Windows.Forms.ToolStripMenuItem newFileToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem newDirectoryToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.ToolStripMenuItem exportToMFSFileToolStripMenuItem; + private System.Windows.Forms.Button button3; } } diff --git a/ShiftOS.MFSProfiler/Main.cs b/ShiftOS.MFSProfiler/Main.cs index 39f087c..41e170e 100644 --- a/ShiftOS.MFSProfiler/Main.cs +++ b/ShiftOS.MFSProfiler/Main.cs @@ -135,9 +135,101 @@ System path: {tvfiles.SelectedNode.Tag.ToString()}"; private void newFileToolStripMenuItem_Click(object sender, EventArgs e) { - var fCreator = new FileCreator(tvfiles.SelectedNode.Tag.ToString()); - if(fCreator.ShowDialog() == DialogResult.OK) + var opener = new OpenFileDialog(); + opener.Title = "Import file into ShiftFS"; + opener.Filter = "All files|*.*"; + opener.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); + if (opener.ShowDialog() == System.Windows.Forms.DialogResult.OK) + { + var bytes = System.IO.File.ReadAllBytes(opener.FileName); + WriteAllBytes(tvfiles.SelectedNode.Tag.ToString() + "/" + opener.SafeFileName, bytes); + SetupTree(); + } + } + + private void button2_Click(object sender, EventArgs e) + { + Infobox.PromptText("Create filesystem", "Please name your file system.", (result) => + { + if(string.IsNullOrWhiteSpace(result)) + MessageBox.Show(text: "ShiftFS does not allow blank volume names.", caption: "Volume name can't be blank", icon: MessageBoxIcon.Error, buttons:MessageBoxButtons.OK); + else + { + var dir = new Directory(); + dir.Name = result; + dir.permissions = Objects.UserPermissions.Guest; + Mounts.Add(dir); + SetupTree(); + } + }); + } + + private void newDirectoryToolStripMenuItem_Click(object sender, EventArgs e) + { + if (DirectoryExists(tvfiles.SelectedNode.Tag.ToString())) { + Infobox.PromptText("New directory", "Please name your directory.", (result) => + { + if (string.IsNullOrWhiteSpace(result)) + MessageBox.Show(text: "ShiftFS does not allow blank directory names.", caption: "Directory name can't be blank", icon: MessageBoxIcon.Error, buttons: MessageBoxButtons.OK); + else + { + var dinf = GetDirectoryInfo(tvfiles.SelectedNode.Tag.ToString()); + dinf.AddDirectory(new Directory + { + Name = result, + permissions = Objects.UserPermissions.Guest + }); + SetupTree(); + } + }); + } + } + + public void Import(string win, string sfs) + { + foreach(var dir in System.IO.Directory.GetDirectories(win)) + { + var dinf = new System.IO.DirectoryInfo(dir); + CreateDirectory(sfs + dinf.Name); + Import(dir, sfs + dinf.Name + "/"); + } + foreach(var file in System.IO.Directory.GetFiles(win)) + { + var finf = new System.IO.FileInfo(file); + WriteAllBytes(sfs + finf.Name, System.IO.File.ReadAllBytes(file)); + } + } + + private void exportToMFSFileToolStripMenuItem_Click(object sender, EventArgs e) + { + string path = tvfiles.SelectedNode.Tag.ToString(); + string[] split = path.Split('/'); + int number = Convert.ToInt32(split[0].Replace(":", "")); + string json = ExportMount(number); + var saver = new SaveFileDialog(); + saver.Filter = "MFS/ShiftFS file (Why the fuck do we also call it \".mfs\"?)|*.mfs"; + saver.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); + if (saver.ShowDialog() == System.Windows.Forms.DialogResult.OK) + { + System.IO.File.WriteAllText(saver.FileName, json); + } + } + + private void button3_Click(object sender, EventArgs e) + { + var picker = new FolderBrowserDialog(); + if(picker.ShowDialog() == DialogResult.OK) + { + var inf = new System.IO.DirectoryInfo(picker.SelectedPath); + var dir = new Directory + { + Name = inf.Name, + permissions = Objects.UserPermissions.Guest, + }; + Mounts.Add(dir); + string mpath = (Mounts.Count - 1) + ":/"; + Import(inf.FullName, mpath); SetupTree(); } } diff --git a/ShiftOS.MFSProfiler/ShiftOS.MFSProfiler.csproj b/ShiftOS.MFSProfiler/ShiftOS.MFSProfiler.csproj index f1f944b..194e038 100644 --- a/ShiftOS.MFSProfiler/ShiftOS.MFSProfiler.csproj +++ b/ShiftOS.MFSProfiler/ShiftOS.MFSProfiler.csproj @@ -52,6 +52,12 @@ <Compile Include="FileCreator.Designer.cs"> <DependentUpon>FileCreator.cs</DependentUpon> </Compile> + <Compile Include="Infobox.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Infobox.Designer.cs"> + <DependentUpon>Infobox.cs</DependentUpon> + </Compile> <Compile Include="Main.cs"> <SubType>Form</SubType> </Compile> @@ -63,6 +69,9 @@ <EmbeddedResource Include="FileCreator.resx"> <DependentUpon>FileCreator.cs</DependentUpon> </EmbeddedResource> + <EmbeddedResource Include="Infobox.resx"> + <DependentUpon>Infobox.cs</DependentUpon> + </EmbeddedResource> <EmbeddedResource Include="Main.resx"> <DependentUpon>Main.cs</DependentUpon> </EmbeddedResource> |
