diff --git a/Sunfish/Sunfish/Configurator/ConfigurationBool.cs b/Sunfish/Sunfish/Configurator/ConfigurationBool.cs new file mode 100644 index 0000000..6bc5390 --- /dev/null +++ b/Sunfish/Sunfish/Configurator/ConfigurationBool.cs @@ -0,0 +1,11 @@ +namespace DolphinWebXplorer2.Configurator +{ + public class ConfigurationBool : ConfigurationElement + { + public ConfigurationBool(string id, string label) : base(id, label) + { + } + + public bool DefaultValue { get; set; } + } +} diff --git a/Sunfish/Sunfish/Configurator/ConfigurationElement.cs b/Sunfish/Sunfish/Configurator/ConfigurationElement.cs index c87cc29..1031e50 100644 --- a/Sunfish/Sunfish/Configurator/ConfigurationElement.cs +++ b/Sunfish/Sunfish/Configurator/ConfigurationElement.cs @@ -1,20 +1,15 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace DolphinWebXplorer2.Configurator +namespace DolphinWebXplorer2.Configurator { public abstract class ConfigurationElement { - protected ConfigurationElement(string id) + protected ConfigurationElement(string id, string label) { Id = id; + Label = label; } public string Id { get; } - public string Label { get; set; } + public string Label { get; } public string Tooltip { get; set; } } } diff --git a/Sunfish/Sunfish/Configurator/ConfigurationMessage.cs b/Sunfish/Sunfish/Configurator/ConfigurationMessage.cs index a218aa3..90234ea 100644 --- a/Sunfish/Sunfish/Configurator/ConfigurationMessage.cs +++ b/Sunfish/Sunfish/Configurator/ConfigurationMessage.cs @@ -1,19 +1,13 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace DolphinWebXplorer2.Configurator +namespace DolphinWebXplorer2.Configurator { - class ConfigurationMessage:ConfigurationElement + class ConfigurationMessage : ConfigurationElement { public enum MessageType { - INFO,WARNING,ERROR + INFO, WARNING, ERROR } - public ConfigurationMessage(MessageType t,string message) : base(null) + public ConfigurationMessage(MessageType t, string message) : base(null, null) { Type = t; Message = message; diff --git a/Sunfish/Sunfish/Configurator/ConfigurationScreen.cs b/Sunfish/Sunfish/Configurator/ConfigurationScreen.cs index 0f64b6d..9e564dd 100644 --- a/Sunfish/Sunfish/Configurator/ConfigurationScreen.cs +++ b/Sunfish/Sunfish/Configurator/ConfigurationScreen.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace DolphinWebXplorer2.Configurator +namespace DolphinWebXplorer2.Configurator { public class ConfigurationScreen { diff --git a/Sunfish/Sunfish/Configurator/ConfigurationString.cs b/Sunfish/Sunfish/Configurator/ConfigurationString.cs index de7bf6c..ef8b5d4 100644 --- a/Sunfish/Sunfish/Configurator/ConfigurationString.cs +++ b/Sunfish/Sunfish/Configurator/ConfigurationString.cs @@ -1,14 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace DolphinWebXplorer2.Configurator +namespace DolphinWebXplorer2.Configurator { - public class ConfigurationString:ConfigurationElement + public class ConfigurationString : ConfigurationElement { - public ConfigurationString(string id) : base(id) + public ConfigurationString(string id, string label) : base(id, label) { } diff --git a/Sunfish/Sunfish/Configurator/SunfishServiceConfigurator.cs b/Sunfish/Sunfish/Configurator/SunfishServiceConfigurator.cs index e381f7d..2f0dbca 100644 --- a/Sunfish/Sunfish/Configurator/SunfishServiceConfigurator.cs +++ b/Sunfish/Sunfish/Configurator/SunfishServiceConfigurator.cs @@ -1,9 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; namespace DolphinWebXplorer2.Configurator { diff --git a/Sunfish/Sunfish/DefineConfigurator.cs b/Sunfish/Sunfish/DefineConfigurator.cs index a9115c9..1966ae4 100644 --- a/Sunfish/Sunfish/DefineConfigurator.cs +++ b/Sunfish/Sunfish/DefineConfigurator.cs @@ -1,9 +1,5 @@ using DolphinWebXplorer2.Configurator; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace DolphinWebXplorer2 { diff --git a/Sunfish/Sunfish/Extensions.cs b/Sunfish/Sunfish/Extensions.cs index 20b1769..d8f5060 100644 --- a/Sunfish/Sunfish/Extensions.cs +++ b/Sunfish/Sunfish/Extensions.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; namespace DolphinWebXplorer2 diff --git a/Sunfish/Sunfish/FServiceConf.Designer.cs b/Sunfish/Sunfish/FServiceConf.Designer.cs index 032a703..1cdd2ad 100644 --- a/Sunfish/Sunfish/FServiceConf.Designer.cs +++ b/Sunfish/Sunfish/FServiceConf.Designer.cs @@ -117,7 +117,7 @@ // btOk // this.btOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btOk.Location = new System.Drawing.Point(282, 217); + this.btOk.Location = new System.Drawing.Point(282, 227); this.btOk.Name = "btOk"; this.btOk.Size = new System.Drawing.Size(113, 38); this.btOk.TabIndex = 7; @@ -129,7 +129,7 @@ // this.btCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.btCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.btCancel.Location = new System.Drawing.Point(408, 217); + this.btCancel.Location = new System.Drawing.Point(408, 227); this.btCancel.Name = "btCancel"; this.btCancel.Size = new System.Drawing.Size(82, 38); this.btCancel.TabIndex = 8; @@ -149,7 +149,7 @@ // btAdv // this.btAdv.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.btAdv.Location = new System.Drawing.Point(12, 217); + this.btAdv.Location = new System.Drawing.Point(12, 227); this.btAdv.Name = "btAdv"; this.btAdv.Size = new System.Drawing.Size(196, 38); this.btAdv.TabIndex = 10; @@ -162,7 +162,7 @@ this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.btCancel; - this.ClientSize = new System.Drawing.Size(502, 267); + this.ClientSize = new System.Drawing.Size(502, 277); this.Controls.Add(this.btAdv); this.Controls.Add(this.pScreen); this.Controls.Add(this.btCancel); diff --git a/Sunfish/Sunfish/FServiceConf.cs b/Sunfish/Sunfish/FServiceConf.cs index c87ad9f..09d5d4f 100644 --- a/Sunfish/Sunfish/FServiceConf.cs +++ b/Sunfish/Sunfish/FServiceConf.cs @@ -1,12 +1,6 @@ using DolphinWebXplorer2.Configurator; 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 DolphinWebXplorer2 @@ -34,7 +28,8 @@ private void LoadData() { - cbType.SelectedItem = ssc.Type; + //cbType.SelectedItem = ssc.Type; + cbType.Text = ssc.Type; cbActive.Checked = ssc.Enabled; tbName.Text = ssc.Name; tbLocation.Text = ssc.Name; @@ -73,14 +68,13 @@ p.Controls.Add(c); } - private void AddElementMessage(ConfigurationElement ce, Panel p, ref int y) + private void AddElementMessage(ConfigurationMessage ce, Panel p, ref int y) { AddElementLabel(ce, p, ref y); - ConfigurationMessage cm = (ConfigurationMessage)ce; Label c = new Label(); - c.Text = cm.Message; + c.Text = ce.Message; c.BorderStyle = BorderStyle.FixedSingle; - switch (cm.Type) + switch (ce.Type) { case ConfigurationMessage.MessageType.ERROR: c.BackColor = Color.FromArgb(255, 200, 200); @@ -99,20 +93,29 @@ FinishElement(c, ce, p, ref y); } - private void AddElementString(ConfigurationElement ce, Panel p, ref int y) + private void AddElementString(ConfigurationString ce, Panel p, ref int y) { AddElementLabel(ce, p, ref y); - ConfigurationString cs = (ConfigurationString)ce; TextBox c = new TextBox(); - c.Text = ssc.GetConf(ce.Id, cs.DefaultValue); + c.Text = ssc.GetConf(ce.Id, ce.DefaultValue); c.Left = 14; c.Width = p.ClientSize.Width - 28; - if (cs.IsPassword) + if (ce.IsPassword) c.PasswordChar = '*'; //TODO: Handle isDirectory and IsFile properties FinishElement(c, ce, p, ref y); } + private void AddElementBool(ConfigurationBool ce, Panel p, ref int y) + { + CheckBox c = new CheckBox(); + c.Text = ce.Label; + c.Checked = ssc.GetConf(ce.Id); + c.Left = 14; + c.Width = p.ClientSize.Width - 28; + FinishElement(c, ce, p, ref y); + } + private void LoadScreen() { // Remove all @@ -131,9 +134,11 @@ foreach (ConfigurationElement ce in cs.Elements) { if (ce is ConfigurationMessage) - AddElementMessage(ce, pScreen, ref y); + AddElementMessage((ConfigurationMessage)ce, pScreen, ref y); else if (ce is ConfigurationString) - AddElementString(ce, pScreen, ref y); + AddElementString((ConfigurationString)ce, pScreen, ref y); + else if (ce is ConfigurationBool) + AddElementBool((ConfigurationBool)ce, pScreen, ref y); } ClientSize = new Size(ClientSize.Width, y + pScreen.Top + panelOffset); } diff --git a/Sunfish/Sunfish/FShared.Designer.cs b/Sunfish/Sunfish/FShared.Designer.cs deleted file mode 100644 index c702123..0000000 --- a/Sunfish/Sunfish/FShared.Designer.cs +++ /dev/null @@ -1,233 +0,0 @@ -namespace DolphinWebXplorer2 -{ - partial class FShared - { - /// - /// Variable del diseñador requerida. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Limpiar los recursos que se estén utilizando. - /// - /// true si los recursos administrados se deben eliminar; false en caso contrario, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Código generado por el Diseñador de Windows Forms - - /// - /// Método necesario para admitir el Diseñador. No se puede modificar - /// el contenido del método con el editor de código. - /// - private void InitializeComponent() - { - this.label1 = new System.Windows.Forms.Label(); - this.tbId = new System.Windows.Forms.TextBox(); - this.tbPath = new System.Windows.Forms.TextBox(); - this.label2 = new System.Windows.Forms.Label(); - this.cbEnabled = new System.Windows.Forms.CheckBox(); - this.cbSub = new System.Windows.Forms.CheckBox(); - this.cbUpl = new System.Windows.Forms.CheckBox(); - this.btOk = new System.Windows.Forms.Button(); - this.cbDele = new System.Windows.Forms.CheckBox(); - this.cbRena = new System.Windows.Forms.CheckBox(); - this.cbExec = new System.Windows.Forms.CheckBox(); - this.btOpen = new System.Windows.Forms.Button(); - this.cbMkDir = new System.Windows.Forms.CheckBox(); - this.cbThumbnails = new System.Windows.Forms.CheckBox(); - this.SuspendLayout(); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(12, 15); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(50, 13); - this.label1.TabIndex = 0; - this.label1.Text = "Identifier:"; - // - // tbId - // - this.tbId.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.tbId.Location = new System.Drawing.Point(68, 12); - this.tbId.Name = "tbId"; - this.tbId.Size = new System.Drawing.Size(323, 20); - this.tbId.TabIndex = 1; - this.tbId.TextChanged += new System.EventHandler(this.tbId_TextChanged); - // - // tbPath - // - this.tbPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.tbPath.Location = new System.Drawing.Point(68, 39); - this.tbPath.Name = "tbPath"; - this.tbPath.Size = new System.Drawing.Size(323, 20); - this.tbPath.TabIndex = 3; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(12, 42); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(32, 13); - this.label2.TabIndex = 2; - this.label2.Text = "Path:"; - // - // cbEnabled - // - this.cbEnabled.AutoSize = true; - this.cbEnabled.Location = new System.Drawing.Point(15, 68); - this.cbEnabled.Name = "cbEnabled"; - this.cbEnabled.Size = new System.Drawing.Size(65, 17); - this.cbEnabled.TabIndex = 4; - this.cbEnabled.Text = "Enabled"; - this.cbEnabled.UseVisualStyleBackColor = true; - // - // cbSub - // - this.cbSub.AutoSize = true; - this.cbSub.Location = new System.Drawing.Point(15, 91); - this.cbSub.Name = "cbSub"; - this.cbSub.Size = new System.Drawing.Size(149, 17); - this.cbSub.TabIndex = 5; - this.cbSub.Text = "Allow subfolder navigation"; - this.cbSub.UseVisualStyleBackColor = true; - // - // cbUpl - // - this.cbUpl.AutoSize = true; - this.cbUpl.Location = new System.Drawing.Point(15, 114); - this.cbUpl.Name = "cbUpl"; - this.cbUpl.Size = new System.Drawing.Size(91, 17); - this.cbUpl.TabIndex = 6; - this.cbUpl.Text = "Allow uploads"; - this.cbUpl.UseVisualStyleBackColor = true; - // - // btOk - // - this.btOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btOk.Location = new System.Drawing.Point(316, 162); - this.btOk.Name = "btOk"; - this.btOk.Size = new System.Drawing.Size(75, 23); - this.btOk.TabIndex = 7; - this.btOk.Text = "Ok"; - this.btOk.UseVisualStyleBackColor = true; - this.btOk.Click += new System.EventHandler(this.btOk_Click); - // - // cbDele - // - this.cbDele.AutoSize = true; - this.cbDele.Location = new System.Drawing.Point(170, 68); - this.cbDele.Name = "cbDele"; - this.cbDele.Size = new System.Drawing.Size(83, 17); - this.cbDele.TabIndex = 8; - this.cbDele.Text = "Allow delete"; - this.cbDele.UseVisualStyleBackColor = true; - // - // cbRena - // - this.cbRena.AutoSize = true; - this.cbRena.Location = new System.Drawing.Point(170, 91); - this.cbRena.Name = "cbRena"; - this.cbRena.Size = new System.Drawing.Size(89, 17); - this.cbRena.TabIndex = 9; - this.cbRena.Text = "Allow rename"; - this.cbRena.UseVisualStyleBackColor = true; - // - // cbExec - // - this.cbExec.AutoSize = true; - this.cbExec.Location = new System.Drawing.Point(170, 114); - this.cbExec.Name = "cbExec"; - this.cbExec.Size = new System.Drawing.Size(229, 17); - this.cbExec.TabIndex = 10; - this.cbExec.Text = "Allow remote execution (execute on server)"; - this.cbExec.UseVisualStyleBackColor = true; - // - // btOpen - // - this.btOpen.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btOpen.Location = new System.Drawing.Point(207, 162); - this.btOpen.Name = "btOpen"; - this.btOpen.Size = new System.Drawing.Size(103, 23); - this.btOpen.TabIndex = 11; - this.btOpen.Text = "Open in browser"; - this.btOpen.UseVisualStyleBackColor = true; - this.btOpen.Click += new System.EventHandler(this.btOpen_Click); - // - // cbMkDir - // - this.cbMkDir.AutoSize = true; - this.cbMkDir.Location = new System.Drawing.Point(15, 137); - this.cbMkDir.Name = "cbMkDir"; - this.cbMkDir.Size = new System.Drawing.Size(118, 17); - this.cbMkDir.TabIndex = 12; - this.cbMkDir.Text = "Allow create folders"; - this.cbMkDir.UseVisualStyleBackColor = true; - // - // cbThumbnails - // - this.cbThumbnails.AutoSize = true; - this.cbThumbnails.Location = new System.Drawing.Point(170, 137); - this.cbThumbnails.Name = "cbThumbnails"; - this.cbThumbnails.Size = new System.Drawing.Size(200, 17); - this.cbThumbnails.TabIndex = 13; - this.cbThumbnails.Text = "Send image previews on icons (slow)"; - this.cbThumbnails.UseVisualStyleBackColor = true; - // - // FShared - // - this.AcceptButton = this.btOk; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(403, 197); - this.Controls.Add(this.cbThumbnails); - this.Controls.Add(this.cbMkDir); - this.Controls.Add(this.btOpen); - this.Controls.Add(this.cbExec); - this.Controls.Add(this.cbRena); - this.Controls.Add(this.cbDele); - this.Controls.Add(this.btOk); - this.Controls.Add(this.cbUpl); - this.Controls.Add(this.cbSub); - this.Controls.Add(this.cbEnabled); - this.Controls.Add(this.tbPath); - this.Controls.Add(this.label2); - this.Controls.Add(this.tbId); - this.Controls.Add(this.label1); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; - this.Name = "FShared"; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Shared"; - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Label label1; - private System.Windows.Forms.TextBox tbId; - private System.Windows.Forms.TextBox tbPath; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.CheckBox cbEnabled; - private System.Windows.Forms.CheckBox cbSub; - private System.Windows.Forms.CheckBox cbUpl; - private System.Windows.Forms.Button btOk; - private System.Windows.Forms.CheckBox cbDele; - private System.Windows.Forms.CheckBox cbRena; - private System.Windows.Forms.CheckBox cbExec; - private System.Windows.Forms.Button btOpen; - private System.Windows.Forms.CheckBox cbMkDir; - private System.Windows.Forms.CheckBox cbThumbnails; - } -} \ No newline at end of file diff --git a/Sunfish/Sunfish/FShared.cs b/Sunfish/Sunfish/FShared.cs deleted file mode 100644 index 9df5787..0000000 --- a/Sunfish/Sunfish/FShared.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Text; -using System.Windows.Forms; -using DolphinWebXplorer2.wx; -using System.Diagnostics; - -namespace DolphinWebXplorer2 -{ - public partial class FShared : Form - { - private bool valid; - private string formerName; - private FShared() - { - InitializeComponent(); - } - - public static bool Execute(WShared sh) - { - using (FShared f = new FShared()) - { - f.tbId.DataBindings.Add("Text", sh, "Name"); - f.tbPath.DataBindings.Add("Text", sh, "Path"); - f.cbEnabled.DataBindings.Add("Checked", sh, "Enabled"); - f.cbSub.DataBindings.Add("Checked", sh, "AllowSubfolders"); - f.cbUpl.DataBindings.Add("Checked", sh, "AllowUpload"); - f.cbDele.DataBindings.Add("Checked", sh, "AllowDeletion"); - f.cbRena.DataBindings.Add("Checked", sh, "AllowRename"); - f.cbExec.DataBindings.Add("Checked", sh, "AllowExecution"); - f.cbMkDir.DataBindings.Add("Checked", sh, "AllowNewFolder"); - f.cbThumbnails.DataBindings.Add("Checked", sh, "SendThumbnails"); - f.formerName = sh.Name; - f.btOpen.Visible=WebXplorer.Contains(sh); - return f.ShowDialog() == DialogResult.OK; - } - } - - private void SaveData() - { - foreach (Control c in new Control[] { tbId, tbPath,cbEnabled,cbSub,cbUpl,cbDele,cbRena,cbExec }) - { - c.DataBindings[0].WriteValue(); - } - } - - private void tbId_TextChanged(object sender, EventArgs e) - { - if (tbId.Text.Contains(" ") || tbId.Text.Contains("|")) - { - tbId.BackColor = Color.FromArgb(255, 200, 200); - valid = false; - return; - } - tbId.BackColor = SystemColors.Window; - valid = true; - } - - private void btOk_Click(object sender, EventArgs e) - { - if (valid) - { - SaveData(); - DialogResult = DialogResult.OK; - } - } - - private void btOpen_Click(object sender, EventArgs e) - { - Process.Start("http://localhost:" + WebXplorer.Port + "/" + formerName+"/"); - } - } -} diff --git a/Sunfish/Sunfish/FShared.resx b/Sunfish/Sunfish/FShared.resx deleted file mode 100644 index 19dc0dd..0000000 --- a/Sunfish/Sunfish/FShared.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Sunfish/Sunfish/Form1.Designer.cs b/Sunfish/Sunfish/Form1.Designer.cs index 88f8d28..b4bc9d8 100644 --- a/Sunfish/Sunfish/Form1.Designer.cs +++ b/Sunfish/Sunfish/Form1.Designer.cs @@ -44,14 +44,8 @@ this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.btShowIp = new System.Windows.Forms.Button(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); - this.btGeneralOptions = new System.Windows.Forms.Button(); - this.cmsGOptions = new System.Windows.Forms.ContextMenuStrip(this.components); - this.shareScreenToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.tstbPassword = new System.Windows.Forms.ToolStripTextBox(); - this.button2 = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.nudPort)).BeginInit(); this.cmsItem.SuspendLayout(); - this.cmsGOptions.SuspendLayout(); this.SuspendLayout(); // // button1 @@ -216,62 +210,11 @@ this.btShowIp.UseVisualStyleBackColor = true; this.btShowIp.Click += new System.EventHandler(this.btShowIp_Click); // - // btGeneralOptions - // - this.btGeneralOptions.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btGeneralOptions.Font = new System.Drawing.Font("Lucida Console", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btGeneralOptions.Image = global::DolphinWebXplorer2.Properties.Resources.run; - this.btGeneralOptions.Location = new System.Drawing.Point(126, 514); - this.btGeneralOptions.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.btGeneralOptions.Name = "btGeneralOptions"; - this.btGeneralOptions.Size = new System.Drawing.Size(34, 35); - this.btGeneralOptions.TabIndex = 9; - this.toolTip1.SetToolTip(this.btGeneralOptions, "General Options"); - this.btGeneralOptions.UseVisualStyleBackColor = true; - this.btGeneralOptions.Click += new System.EventHandler(this.btGeneralOptions_Click); - // - // cmsGOptions - // - this.cmsGOptions.ImageScalingSize = new System.Drawing.Size(24, 24); - this.cmsGOptions.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.shareScreenToolStripMenuItem}); - this.cmsGOptions.Name = "cmsGOptions"; - this.cmsGOptions.Size = new System.Drawing.Size(186, 36); - // - // shareScreenToolStripMenuItem - // - this.shareScreenToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.tstbPassword}); - this.shareScreenToolStripMenuItem.Name = "shareScreenToolStripMenuItem"; - this.shareScreenToolStripMenuItem.Size = new System.Drawing.Size(185, 32); - this.shareScreenToolStripMenuItem.Text = "Share Screen"; - this.shareScreenToolStripMenuItem.Click += new System.EventHandler(this.shareScreenToolStripMenuItem_Click); - // - // tstbPassword - // - this.tstbPassword.Name = "tstbPassword"; - this.tstbPassword.Size = new System.Drawing.Size(100, 31); - this.tstbPassword.ToolTipText = "Password"; - this.tstbPassword.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.tstbPassword_KeyPress); - this.tstbPassword.TextChanged += new System.EventHandler(this.tstbPassword_TextChanged); - // - // button2 - // - this.button2.Location = new System.Drawing.Point(9, 9); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(103, 32); - this.button2.TabIndex = 10; - this.button2.Text = "Test 2"; - this.button2.UseVisualStyleBackColor = true; - this.button2.Click += new System.EventHandler(this.button2_Click_1); - // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(360, 558); - this.Controls.Add(this.button2); - this.Controls.Add(this.btGeneralOptions); this.Controls.Add(this.btShowIp); this.Controls.Add(this.lbPaths); this.Controls.Add(this.btSub); @@ -289,7 +232,6 @@ this.LocationChanged += new System.EventHandler(this.Form1_Activated); ((System.ComponentModel.ISupportInitialize)(this.nudPort)).EndInit(); this.cmsItem.ResumeLayout(false); - this.cmsGOptions.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -306,16 +248,11 @@ private System.Windows.Forms.Button btShowIp; private System.Windows.Forms.ToolTip toolTip1; private System.Windows.Forms.ImageList il16; - private System.Windows.Forms.Button btGeneralOptions; private System.Windows.Forms.ContextMenuStrip cmsItem; private System.Windows.Forms.ToolStripMenuItem editarToolStripMenuItem; - private System.Windows.Forms.ContextMenuStrip cmsGOptions; - private System.Windows.Forms.ToolStripMenuItem shareScreenToolStripMenuItem; - private System.Windows.Forms.ToolStripTextBox tstbPassword; private System.Windows.Forms.ToolStripMenuItem añadirToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem borrarToolStripMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; - private System.Windows.Forms.Button button2; } } diff --git a/Sunfish/Sunfish/Form1.cs b/Sunfish/Sunfish/Form1.cs index 1d0273b..688dd2a 100644 --- a/Sunfish/Sunfish/Form1.cs +++ b/Sunfish/Sunfish/Form1.cs @@ -1,14 +1,14 @@ -using System; +using DolphinWebXplorer2.Properties; +using DolphinWebXplorer2.wx; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; -using System.Text; -using System.Windows.Forms; -using DolphinWebXplorer2.wx; -using DolphinWebXplorer2.Properties; using System.IO; using System.Net.NetworkInformation; using System.Net.Sockets; +using System.Text; +using System.Windows.Forms; namespace DolphinWebXplorer2 { @@ -50,6 +50,29 @@ return result; } + private void EditConfiguration(SunfishServiceConfiguration ssc, SunfishService oldService) + { + if (FServiceConf.Execute(ssc)) + { + if (oldService == null) try + { + lbPaths.Items.Add(Sunfish.AddService(ssc)); + Sunfish.Save(); + } + catch (Exception ex) + { + ex.Show(); + } + else + { + //oldService + //TODO: How to update service according to configuration changes? + //Sunfish. + lbPaths.Update(); + } + } + } + public Screen MyScreen { get { lock (this) return myscreen; } } private void button1_Click(object sender, EventArgs e) @@ -89,35 +112,7 @@ private void btAdd_Click(object sender, EventArgs e) { SunfishServiceConfiguration ssc = new SunfishServiceConfiguration(); - if (FServiceConf.Execute(ssc)) - { - try - { - lbPaths.Items.Add(Sunfish.AddService(ssc)); - Sunfish.Save(); - } - catch (Exception ex) - { - ex.Show(); - } - } - //WShared sh; - //string clip = Clipboard.GetText(); - //if ((Path.DirectorySeparatorChar == '/' ? clip.Length > 0 && clip[0] == '/' : clip.Length > 2 && clip[1] == ':' && clip[2] == '\\') - // && (Directory.Exists(clip) || File.Exists(clip))) - //{ - // if (File.Exists(clip)) - // clip = Path.GetDirectoryName(clip); - // sh = new WShared(Path.GetFileName(clip), clip); - //} - //else - // sh = new WShared("NewShared", @"C:\"); - //sh.Enabled = true; - //if (FShared.Execute(sh)) - //{ - // WebXplorer.Add(sh); - // lbPaths.Items.Add(sh); - //} + EditConfiguration(ssc, null); } private void clbPaths_DoubleClick(object sender, EventArgs e) @@ -125,11 +120,7 @@ SunfishService s = (SunfishService)lbPaths.SelectedItem; if (s == null) return; - if (FServiceConf.Execute(s.Configuration)) - { - //TODO: How to update service according to configuration changes? - lbPaths.Update(); - } + EditConfiguration(s.Configuration, s); } private void lbPaths_DrawItem(object sender, DrawItemEventArgs e) @@ -217,22 +208,6 @@ Clipboard.SetText(tsi.Tag.ToString()); } - private void btGeneralOptions_Click(object sender, EventArgs e) - { - cmsGOptions.Show(btGeneralOptions, new Point(0, btGeneralOptions.Height)); - } - - private void shareScreenToolStripMenuItem_Click(object sender, EventArgs e) - { - WebXplorer.SharedScreen = !WebXplorer.SharedScreen; - shareScreenToolStripMenuItem.Checked = WebXplorer.SharedScreen; - } - - private void tstbPassword_TextChanged(object sender, EventArgs e) - { - WebXplorer.SharedScreenPassword = tstbPassword.Text; - } - private void tstbPassword_KeyPress(object sender, KeyPressEventArgs e) { e.KeyChar = char.ToLower(e.KeyChar); @@ -259,25 +234,20 @@ { foreach (string file in files) { - WShared sh; + SunfishServiceConfiguration ssc = new SunfishServiceConfiguration(); + ssc.Type = "WebService"; string fil = file; if (!Directory.Exists(file)) fil = Path.GetDirectoryName(fil); - sh = new WShared(Path.GetFileName(fil), fil); - sh.Enabled = true; - if (FShared.Execute(sh)) - { - WebXplorer.Add(sh); - lbPaths.Items.Add(sh); - } + ssc.Name = Path.GetFileName(fil); + ssc.Location = Path.GetFileName(fil); + ssc.Enabled = true; + ssc.Settings[Services.WebServiceConfigurator.CFG_PATH] = fil; + EditConfiguration(ssc, null); } Activate(); } } - private void button2_Click_1(object sender, EventArgs e) - { - Sunfish.Save(); - } } } diff --git a/Sunfish/Sunfish/Form1.resx b/Sunfish/Sunfish/Form1.resx index 9f39972..79d5451 100644 --- a/Sunfish/Sunfish/Form1.resx +++ b/Sunfish/Sunfish/Form1.resx @@ -128,7 +128,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAq - AQAAAk1TRnQBSQFMAgEBAgEAAWgBAAFoAQABEAEAARABAAT/AQUBAAj/AUIBTQF2BwABdgMAASgDAAFA + AQAAAk1TRnQBSQFMAgEBAgEAAXABAAFwAQABEAEAARABAAT/AQUBAAj/AUIBTQF2BwABdgMAASgDAAFA AwABEAMAAQEBAAEEBgABAhgAAYACAAGAAwACgAEAAYADAAGAAQABgAEAAoACAAPAAQADgAMAAf8CAAH/ AwAC/wEAAf8DAAH/AQAB/wEAAv8CAAP//wD/AAMAAUIBTQE+BwABPgMAASgDAAFAAwABEAMAAQEBAAEB BQABgBcAA/8BAAT/BAAE/wQABP8EAAH8AT8C/wQAAfwBPwL/BAAB/AE/Av8EAAHgAQcB4AEHBAAB4AEH @@ -142,7 +142,4 @@ 185, 17 - - 283, 17 - \ No newline at end of file diff --git a/Sunfish/Sunfish/IpInfo.cs b/Sunfish/Sunfish/IpInfo.cs index f468d71..673863e 100644 --- a/Sunfish/Sunfish/IpInfo.cs +++ b/Sunfish/Sunfish/IpInfo.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.NetworkInformation; -using System.Text; +using System.Net.NetworkInformation; namespace DolphinWebXplorer2 { diff --git a/Sunfish/Sunfish/Library/Json.Net/IJsonConverter.cs b/Sunfish/Sunfish/Library/Json.Net/IJsonConverter.cs index 81836af..1bb2c86 100644 --- a/Sunfish/Sunfish/Library/Json.Net/IJsonConverter.cs +++ b/Sunfish/Sunfish/Library/Json.Net/IJsonConverter.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.IO; -using System.Text; namespace Json.Net { diff --git a/Sunfish/Sunfish/Library/Json.Net/JsonConverter.cs b/Sunfish/Sunfish/Library/Json.Net/JsonConverter.cs index 9ba36da..1c4556b 100644 --- a/Sunfish/Sunfish/Library/Json.Net/JsonConverter.cs +++ b/Sunfish/Sunfish/Library/Json.Net/JsonConverter.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; namespace Json.Net { diff --git a/Sunfish/Sunfish/Library/Json.Net/JsonParser.cs b/Sunfish/Sunfish/Library/Json.Net/JsonParser.cs index c27358f..7106629 100644 --- a/Sunfish/Sunfish/Library/Json.Net/JsonParser.cs +++ b/Sunfish/Sunfish/Library/Json.Net/JsonParser.cs @@ -1,10 +1,10 @@ using System; -using System.Collections.Generic; -using System.IO; -using System.Text; using System.Collections; +using System.Collections.Generic; using System.Globalization; +using System.IO; using System.Linq; +using System.Text; namespace Json.Net @@ -17,7 +17,7 @@ IJsonConverter[] Converters; IPropertyNameTransform PropertyNameTransform; - static Dictionary EscapeMap = + static Dictionary EscapeMap = new Dictionary() { { 'b', (char)8 }, @@ -62,7 +62,7 @@ PropertyNameTransform = options.PropertyNameTransform; return this; } - + StringBuilder text = new StringBuilder(); @@ -92,7 +92,7 @@ var mIndex = 0; - while (NextChar!='}') + while (NextChar != '}') { var name = (string)FromJson(nameType); @@ -142,7 +142,7 @@ break; } - + Match("}"); return result; @@ -255,7 +255,7 @@ if (type == typeof(DateTimeOffset) || type == typeof(DateTimeOffset?)) return DateTimeOffset.Parse((string)result, CultureInfo.InvariantCulture); - + if (type == typeof(TimeSpan) || type == typeof(TimeSpan?)) return TimeSpan.Parse((string)result, CultureInfo.InvariantCulture); diff --git a/Sunfish/Sunfish/Library/Json.Net/JsonSerializer.cs b/Sunfish/Sunfish/Library/Json.Net/JsonSerializer.cs index dd1fa4f..b2e3f11 100644 --- a/Sunfish/Sunfish/Library/Json.Net/JsonSerializer.cs +++ b/Sunfish/Sunfish/Library/Json.Net/JsonSerializer.cs @@ -50,8 +50,8 @@ } } - - static Dictionary> SerializerCache = + + static Dictionary> SerializerCache = new Dictionary>(); @@ -74,17 +74,17 @@ } Func cnv; - Type genericType; + Type genericType; if (!SerializerCache.TryGetValue(objectType, out cnv)) { var strConverter = new Func( - s => + s => { var t = (string)s; var r = "\""; - for (var i = 0;i v.ValueType) - .Where(t => t != typeof(string) + .Where(t => t != typeof(string) && (t.IsClass || (t.IsValueType && !t.IsPrimitive))) .Except(GlobalMaps.Select(m => m.ObjectType)) .Distinct()) @@ -90,6 +88,6 @@ return result; } - + } } diff --git a/Sunfish/Sunfish/Middleware/HttpServer.cs b/Sunfish/Sunfish/Middleware/HttpServer.cs index 07b6c8b..04f6b58 100644 --- a/Sunfish/Sunfish/Middleware/HttpServer.cs +++ b/Sunfish/Sunfish/Middleware/HttpServer.cs @@ -1,10 +1,10 @@ - using System; +using System; using System.Collections.Generic; -using System.Text; using System.IO; using System.Net; -using System.Web; +using System.Text; using System.Threading; +using System.Web; namespace DolphinWebXplorer2.Middleware { @@ -276,7 +276,7 @@ { private string contentType; private Dictionary parms; - private Dictionary files=new Dictionary(); + private Dictionary files = new Dictionary(); private HttpServerProcessor owner; private Encoding encoding; private static char[] CRLF = { '\r', '\n' }; @@ -303,7 +303,7 @@ ReadMultipart(input); else if ("application/x-www-form-urlencoded".Equals(cttp[0], StringComparison.InvariantCultureIgnoreCase)) - ReadPost(input); + ReadPost(input); } private void ReadPost(Stream input) @@ -324,7 +324,7 @@ private void ReadMultipart(Stream input) { - mimeBoundary = "--"+parms["boundary"]; + mimeBoundary = "--" + parms["boundary"]; BinaryReader br = new BinaryReader(input, encoding); string bnd = ReadLine(br); if (bnd == mimeBoundary + "--") @@ -359,7 +359,7 @@ bool eq = true; for (int i = 0; i < signal.Length; i++) { - if (signal[i]!=chars[(chars.Count-signal.Length)+i]) + if (signal[i] != chars[(chars.Count - signal.Length) + i]) { eq = false; break; @@ -368,7 +368,7 @@ if (eq) { char[] chs = chars.ToArray(); - return new string(chs,0,chs.Length-signal.Length); + return new string(chs, 0, chs.Length - signal.Length); } } } @@ -418,7 +418,7 @@ { byte[] data = ReadUntil(br, mimeBoundaryBytes); string fname = cdisp["filename"]; - if (fname.Length>0) + if (fname.Length > 0) files[cdisp["name"]] = new HttpPostFile(fname, data); } else @@ -435,16 +435,17 @@ throw new Exception("Error reading multipart (" + ch1 + ch2 + ")"); } - private Dictionary GetContentDisposition(Dictionary hdrs) + private Dictionary GetContentDisposition(Dictionary hdrs) { if (!hdrs.ContainsKey("Content-Disposition")) return null; Dictionary result = new Dictionary(); - foreach (string cd in hdrs["Content-Disposition"].Split(';')){ + foreach (string cd in hdrs["Content-Disposition"].Split(';')) + { int pos = cd.IndexOf("="); if (pos < 0) continue; - string name = cd.Substring(1, pos-1); + string name = cd.Substring(1, pos - 1); string var = cd.Substring(pos + 1); if (var.Length > 0 && var[0] == '"') var = var.Substring(1, var.Length - 2); diff --git a/Sunfish/Sunfish/Middleware/Win32.cs b/Sunfish/Sunfish/Middleware/Win32.cs index 4c4dacf..a7da4e7 100644 --- a/Sunfish/Sunfish/Middleware/Win32.cs +++ b/Sunfish/Sunfish/Middleware/Win32.cs @@ -1,10 +1,6 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Runtime.InteropServices; using System.Drawing; -using System.ComponentModel; +using System.Runtime.InteropServices; namespace DolphinWebXplorer2.Middleware { diff --git a/Sunfish/Sunfish/Properties/AssemblyInfo.cs b/Sunfish/Sunfish/Properties/AssemblyInfo.cs index 05dac11..bdd24ce 100644 --- a/Sunfish/Sunfish/Properties/AssemblyInfo.cs +++ b/Sunfish/Sunfish/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // La información general sobre un ensamblado se controla mediante el siguiente diff --git a/Sunfish/Sunfish/Services/AdminService.cs b/Sunfish/Sunfish/Services/AdminService.cs index 0dfca17..4d5647e 100644 --- a/Sunfish/Sunfish/Services/AdminService.cs +++ b/Sunfish/Sunfish/Services/AdminService.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace DolphinWebXplorer2.Services +namespace DolphinWebXplorer2.Services { [DefineConfigurator(typeof(AdminServiceConfigurator))] class AdminService : SunfishService diff --git a/Sunfish/Sunfish/Services/AdminServiceConfigurator.cs b/Sunfish/Sunfish/Services/AdminServiceConfigurator.cs index 9761040..a301577 100644 --- a/Sunfish/Sunfish/Services/AdminServiceConfigurator.cs +++ b/Sunfish/Sunfish/Services/AdminServiceConfigurator.cs @@ -1,27 +1,21 @@ using DolphinWebXplorer2.Configurator; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace DolphinWebXplorer2.Services { class AdminServiceConfigurator : SunfishServiceConfigurator { internal const string CFG_ADMIN_PWD = "adminPwd"; - + internal protected override ConfigurationScreen GetConfigurationScreen() { return new ConfigurationScreen() { Elements = new ConfigurationElement[] { - new ConfigurationString(CFG_ADMIN_PWD) + new ConfigurationString(CFG_ADMIN_PWD,"Admin password: (blank for none)") { Tooltip="Password for the administration panel.\n Leave it blank for no password access (not recommended)", IsPassword=true, - Label="Admin password: (blank for none)" } } }; diff --git a/Sunfish/Sunfish/Services/ErrorService.cs b/Sunfish/Sunfish/Services/ErrorService.cs index 765c338..320bb12 100644 --- a/Sunfish/Sunfish/Services/ErrorService.cs +++ b/Sunfish/Sunfish/Services/ErrorService.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace DolphinWebXplorer2.Services +namespace DolphinWebXplorer2.Services { [DefineConfigurator(typeof(ErrorServiceConfigurator))] class ErrorService : SunfishService diff --git a/Sunfish/Sunfish/Services/ErrorServiceConfigurator.cs b/Sunfish/Sunfish/Services/ErrorServiceConfigurator.cs index 65bbd9d..14651ac 100644 --- a/Sunfish/Sunfish/Services/ErrorServiceConfigurator.cs +++ b/Sunfish/Sunfish/Services/ErrorServiceConfigurator.cs @@ -1,9 +1,4 @@ using DolphinWebXplorer2.Configurator; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace DolphinWebXplorer2.Services { diff --git a/Sunfish/Sunfish/Services/WebService.cs b/Sunfish/Sunfish/Services/WebService.cs index 701ec05..c1fb328 100644 --- a/Sunfish/Sunfish/Services/WebService.cs +++ b/Sunfish/Sunfish/Services/WebService.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace DolphinWebXplorer2.Services +namespace DolphinWebXplorer2.Services { [DefineConfigurator(typeof(WebServiceConfigurator))] class WebService : SunfishService diff --git a/Sunfish/Sunfish/Services/WebServiceConfigurator.cs b/Sunfish/Sunfish/Services/WebServiceConfigurator.cs index 3c07ca0..c6b42c9 100644 --- a/Sunfish/Sunfish/Services/WebServiceConfigurator.cs +++ b/Sunfish/Sunfish/Services/WebServiceConfigurator.cs @@ -1,15 +1,11 @@ using DolphinWebXplorer2.Configurator; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace DolphinWebXplorer2.Services { class WebServiceConfigurator : SunfishServiceConfigurator { internal const string CFG_PATH = "path"; + internal const string CFG_INDEX = "defaultFile"; internal const string CFG_SHARE = "folderShare"; internal const string CFG_NAVIGATION = "allowSubfolderNavigation"; internal const string CFG_UPLOAD = "allowUploads"; @@ -28,12 +24,40 @@ { Elements = new ConfigurationElement[] { - new ConfigurationString(CFG_PATH) + new ConfigurationString(CFG_PATH,"Web path") { Tooltip = "Folder, zip or web-file path of site document root", - Label = "Web path", IsDirectoiryPath = true, IsFilePath = true, + }, + new ConfigurationString(CFG_INDEX,"Default document") + { + Tooltip = "Default document for directory path", + DefaultValue ="index.html" + }, + new ConfigurationBool(CFG_SHARE,"Folder share") + { + Tooltip ="Allow directory listings, switched off the server will report a forbidden message if the directory has no default file." + }, + new ConfigurationBool(CFG_NAVIGATION,"Subfolder navigation") + { + Tooltip ="Allow subfolder navigation." + }, + new ConfigurationBool(CFG_UPLOAD,"Allow upload") + { + Tooltip ="Allow upload of files and folders." + }, + new ConfigurationBool(CFG_RENAME,"Allow rename") + { + Tooltip ="Allow raname of server files and folders." + }, + new ConfigurationBool(CFG_DELETE,"Allow delete") + { + Tooltip ="Allow delete files and folders." + }, + new ConfigurationBool(CFG_EXECUTE,"Allow execute") + { + Tooltip ="Allow application execution on server." } }, Advanced = AdvancedEditing diff --git a/Sunfish/Sunfish/Sunfish.cs b/Sunfish/Sunfish/Sunfish.cs index c2c843d..fe21647 100644 --- a/Sunfish/Sunfish/Sunfish.cs +++ b/Sunfish/Sunfish/Sunfish.cs @@ -1,9 +1,6 @@ using Json.Net; -using System; using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; namespace DolphinWebXplorer2 { diff --git a/Sunfish/Sunfish/Sunfish.csproj b/Sunfish/Sunfish/Sunfish.csproj index 3d1392c..167130c 100644 --- a/Sunfish/Sunfish/Sunfish.csproj +++ b/Sunfish/Sunfish/Sunfish.csproj @@ -75,6 +75,7 @@ + Form @@ -88,12 +89,6 @@ FServiceConf.cs - - Form - - - FShared.cs - @@ -115,9 +110,6 @@ FServiceConf.cs - - FShared.cs - ResXFileCodeGenerator Resources.Designer.cs diff --git a/Sunfish/Sunfish/SunfishService.cs b/Sunfish/Sunfish/SunfishService.cs index b5b94b2..4eff264 100644 --- a/Sunfish/Sunfish/SunfishService.cs +++ b/Sunfish/Sunfish/SunfishService.cs @@ -2,10 +2,7 @@ using DolphinWebXplorer2.Services; using System; using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; namespace DolphinWebXplorer2 { diff --git a/Sunfish/Sunfish/SunfishServiceConfiguration.cs b/Sunfish/Sunfish/SunfishServiceConfiguration.cs index 7e654f7..5f4f0fa 100644 --- a/Sunfish/Sunfish/SunfishServiceConfiguration.cs +++ b/Sunfish/Sunfish/SunfishServiceConfiguration.cs @@ -1,18 +1,14 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; namespace DolphinWebXplorer2 { public class SunfishServiceConfiguration { - public string GetConf(string key, string def = null) + public T GetConf(string key, T def = default) { - string value; + object value; if (Settings.TryGetValue(key, out value)) - return value; + return (T) value; return def; } @@ -20,6 +16,6 @@ public string Name { get; set; } public bool Enabled { get; set; } public string Location { get; set; } - public Dictionary Settings { get; set; } = new Dictionary(); + public Dictionary Settings { get; set; } = new Dictionary(); } } diff --git a/Sunfish/Sunfish/wx/RemoteScreen.cs b/Sunfish/Sunfish/wx/RemoteScreen.cs index fbddb65..eadba9c 100644 --- a/Sunfish/Sunfish/wx/RemoteScreen.cs +++ b/Sunfish/Sunfish/wx/RemoteScreen.cs @@ -1,11 +1,8 @@ using System; -using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; using System.IO; -using System.Linq; using System.Runtime.InteropServices; -using System.Text; using System.Threading; using System.Windows.Forms; @@ -58,7 +55,7 @@ q = 15; else { - q = 80-(diff / 100000L); + q = 80 - (diff / 100000L); if (q < 15) q = 15; } diff --git a/Sunfish/Sunfish/wx/WShared.cs b/Sunfish/Sunfish/wx/WShared.cs index 1dd7020..aba0d27 100644 --- a/Sunfish/Sunfish/wx/WShared.cs +++ b/Sunfish/Sunfish/wx/WShared.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; +using System.Linq; using System.Text; namespace DolphinWebXplorer2.wx @@ -30,12 +28,12 @@ public string GetLocalPath(string path) { - return this.path + path.Replace('/',System.IO.Path.DirectorySeparatorChar); + return this.path + path.Replace('/', System.IO.Path.DirectorySeparatorChar); } public string GetRemotePath(string path) { - return '/' + name +'/'+ path; + return '/' + name + '/' + path; } public string GetFlags() @@ -53,7 +51,7 @@ public void SetFlags(string flags) { - allowSubfolders=flags.Contains('S'); + allowSubfolders = flags.Contains('S'); allowUpload = flags.Contains('U'); allowDeletion = flags.Contains('D'); allowRename = flags.Contains('R'); diff --git a/Sunfish/Sunfish/wx/WebXplorer.cs b/Sunfish/Sunfish/wx/WebXplorer.cs index ac1320c..68c3614 100644 --- a/Sunfish/Sunfish/wx/WebXplorer.cs +++ b/Sunfish/Sunfish/wx/WebXplorer.cs @@ -1,18 +1,15 @@ -using System; +using DolphinWebXplorer2.Middleware; +using DolphinWebXplorer2.Properties; +using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Net; -using System.Windows.Forms; -using System.Diagnostics; -using System.IO; using System.Drawing; using System.Drawing.Imaging; -using DolphinWebXplorer2.Properties; +using System.IO; +using System.Linq; +using System.Net; using System.Reflection; -using System.Threading; -using System.Runtime.InteropServices; -using DolphinWebXplorer2.Middleware; +using System.Text; +using System.Windows.Forms; namespace DolphinWebXplorer2.wx { @@ -51,7 +48,7 @@ res_upload = GetImageData(Resources.upload, ImageFormat.Png); Win32.DestroyIcon(Win32.GetIcon(".").hIcon); string letters = "abcdefghikjlmnopqrstuvwxyz1234567890"; - Random rnd=new Random(); + Random rnd = new Random(); sharedScreenPwd = ""; while (sharedScreenPwd.Length < 10) sharedScreenPwd += letters[rnd.Next(letters.Length)]; @@ -156,7 +153,7 @@ Stop(); foreach (string l in data) { - if (l.StartsWith("#") || l.Length==0) + if (l.StartsWith("#") || l.Length == 0) continue; int dp = l.IndexOf(':'); if (dp < 0) @@ -209,7 +206,7 @@ return result; } - public static bool CheckACode(string key,string acode) + public static bool CheckACode(string key, string acode) { if (acodes.ContainsKey(key)) { @@ -295,9 +292,9 @@ } else if (sh.Enabled) - Shared(sh, rpath); - else - Menu(); + Shared(sh, rpath); + else + Menu(); } } @@ -503,7 +500,7 @@ } #region Action Pages - private const string RESETURL=""; + private const string RESETURL = ""; private void PageRename(WShared sh, string path) { @@ -534,13 +531,13 @@ Header(sh.Name, sh, path.Split('/')); if (!sh.AllowRename) Error("Forbidden", "Renaming is not allowed on this site"); - else if (!WebXplorer.CheckACode("R" + path,GET["acode"])) + else if (!WebXplorer.CheckACode("R" + path, GET["acode"])) Error("Auth code error", RESETURL); else { string dir = System.IO.Path.GetDirectoryName(path); - if (!dir.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()) && !(dir.Length==0)) - dir+=System.IO.Path.DirectorySeparatorChar; + if (!dir.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()) && !(dir.Length == 0)) + dir += System.IO.Path.DirectorySeparatorChar; string oname = System.IO.Path.GetFileName(path); string nname = GET["newname"]; if (oname != nname) @@ -659,7 +656,7 @@ string dname = GET["dirname"]; if (dname.Contains("/") || dname.Contains("\\") || dname.Contains(":")) Error("Create directory error", "Path separator char not allowed as file name"); - string dir = path.Replace('/',System.IO.Path.DirectorySeparatorChar); + string dir = path.Replace('/', System.IO.Path.DirectorySeparatorChar); if (!dir.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()) && !(dir.Length == 0)) dir += System.IO.Path.DirectorySeparatorChar; try @@ -724,7 +721,7 @@ } Footer(); } -#endregion + #endregion private void BlackHeader(string title, string script) { @@ -759,7 +756,7 @@ string fpath = "/"; if (sh != null) { - string shared=sh.Name; + string shared = sh.Name; fpath += shared + "/"; Out.Write("