mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
A lof refactoring. There is a problem in PortableSettingsProvider.cs where it doesn't save the config file. We need to address PortableSettingsProvider.SetPropertyValues() method that saves the config file is not called at all.
This commit is contained in:
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.Forms;
|
||||
using mRemoteNG.Config.Connections;
|
||||
using mRemoteNG.UI.Forms;
|
||||
|
||||
|
||||
namespace mRemoteNG.App
|
||||
@@ -30,7 +31,7 @@ namespace mRemoteNG.App
|
||||
exportForm.SelectedConnection = selectedTreeNode;
|
||||
}
|
||||
|
||||
if (!(exportForm.ShowDialog(frmMain.Default) == DialogResult.OK))
|
||||
if (exportForm.ShowDialog(frmMain.Default) != DialogResult.OK)
|
||||
{
|
||||
return ;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.UI.Forms;
|
||||
|
||||
namespace mRemoteNG.App
|
||||
{
|
||||
|
||||
@@ -21,6 +21,7 @@ using System.IO;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml;
|
||||
using mRemoteNG.UI.Forms;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.UI.Forms;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
|
||||
namespace mRemoteNG.App
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using mRemoteNG.Tools;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using mRemoteNG.UI.Forms;
|
||||
|
||||
namespace mRemoteNG.App
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@ using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
using mRemoteNG.Config.Connections;
|
||||
using mRemoteNG.UI.Forms;
|
||||
|
||||
namespace mRemoteNG.App
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@ using mRemoteNG.Connection;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Images;
|
||||
using mRemoteNG.UI.Forms;
|
||||
|
||||
|
||||
namespace mRemoteNG.Config.Connections
|
||||
|
||||
@@ -11,6 +11,7 @@ using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml;
|
||||
using mRemoteNG.UI.Forms;
|
||||
|
||||
|
||||
namespace mRemoteNG.Config.Connections
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Specialized;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml;
|
||||
|
||||
@@ -9,41 +10,38 @@ namespace mRemoteNG.Config.Settings.Providers
|
||||
{
|
||||
public class PortableSettingsProvider : SettingsProvider
|
||||
{
|
||||
const string SETTINGSROOT = "Settings"; //XML Root Node
|
||||
const string SETTINGSROOT = "Settings"; //XML Root Node
|
||||
|
||||
public override void Initialize(string name, NameValueCollection col)
|
||||
{
|
||||
base.Initialize(this.ApplicationName, col);
|
||||
}
|
||||
|
||||
base.Initialize(ApplicationName, col);
|
||||
|
||||
if (Application.ProductName.Trim().Length > 0)
|
||||
{
|
||||
_applicationName = Application.ProductName;
|
||||
}
|
||||
else
|
||||
{
|
||||
_applicationName = Path.GetFileNameWithoutExtension(Application.ExecutablePath);
|
||||
}
|
||||
}
|
||||
|
||||
private string _applicationName;
|
||||
public override string ApplicationName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (System.Windows.Forms.Application.ProductName.Trim().Length > 0)
|
||||
{
|
||||
return System.Windows.Forms.Application.ProductName;
|
||||
}
|
||||
else
|
||||
{
|
||||
System.IO.FileInfo fi = new System.IO.FileInfo(System.Windows.Forms.Application.ExecutablePath);
|
||||
return fi.Name.Substring(0, fi.Name.Length - fi.Extension.Length);
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
//Do nothing
|
||||
}
|
||||
}
|
||||
|
||||
virtual public string GetAppSettingsPath()
|
||||
{
|
||||
get { return _applicationName; }
|
||||
set { }
|
||||
}
|
||||
|
||||
|
||||
public virtual string GetAppSettingsPath()
|
||||
{
|
||||
//Used to determine where to store the settings
|
||||
System.IO.FileInfo fi = new System.IO.FileInfo(Application.ExecutablePath);
|
||||
return fi.DirectoryName;
|
||||
}
|
||||
|
||||
virtual public string GetAppSettingsFilename()
|
||||
public virtual string GetAppSettingsFilename()
|
||||
{
|
||||
//Used to determine the filename to store the settings
|
||||
return "portable.config"; //ApplicationName & ".settings"
|
||||
@@ -60,7 +58,7 @@ namespace mRemoteNG.Config.Settings.Providers
|
||||
|
||||
try
|
||||
{
|
||||
SettingsXML.Save(System.IO.Path.Combine(GetAppSettingsPath(), GetAppSettingsFilename()));
|
||||
SettingsXml.Save(Path.Combine(GetAppSettingsPath(), GetAppSettingsFilename()));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -71,77 +69,70 @@ namespace mRemoteNG.Config.Settings.Providers
|
||||
public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context, SettingsPropertyCollection props)
|
||||
{
|
||||
//Create new collection of values
|
||||
SettingsPropertyValueCollection values = new SettingsPropertyValueCollection();
|
||||
var values = new SettingsPropertyValueCollection();
|
||||
|
||||
//Iterate through the settings to be retrieved
|
||||
foreach (SettingsProperty setting in props)
|
||||
{
|
||||
|
||||
SettingsPropertyValue value = new SettingsPropertyValue(setting);
|
||||
value.IsDirty = false;
|
||||
value.SerializedValue = GetValue(setting);
|
||||
values.Add(value);
|
||||
|
||||
var value = new SettingsPropertyValue(setting)
|
||||
{
|
||||
IsDirty = false,
|
||||
SerializedValue = GetValue(setting)
|
||||
};
|
||||
values.Add(value);
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
private System.Xml.XmlDocument m_SettingsXML = null;
|
||||
private XmlDocument _SettingsXml;
|
||||
|
||||
private System.Xml.XmlDocument SettingsXML
|
||||
private XmlDocument SettingsXml
|
||||
{
|
||||
get
|
||||
{
|
||||
//If we dont hold an xml document, try opening one.
|
||||
//If it doesnt exist then create a new one ready.
|
||||
if (m_SettingsXML == null)
|
||||
if (_SettingsXml == null)
|
||||
{
|
||||
m_SettingsXML = new System.Xml.XmlDocument();
|
||||
_SettingsXml = new XmlDocument();
|
||||
|
||||
try
|
||||
{
|
||||
m_SettingsXML.Load(System.IO.Path.Combine(GetAppSettingsPath(), GetAppSettingsFilename()));
|
||||
_SettingsXml.Load(System.IO.Path.Combine(GetAppSettingsPath(), GetAppSettingsFilename()));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//Create new document
|
||||
XmlDeclaration dec = m_SettingsXML.CreateXmlDeclaration("1.0", "utf-8", string.Empty);
|
||||
m_SettingsXML.AppendChild(dec);
|
||||
|
||||
XmlNode nodeRoot = default(XmlNode);
|
||||
|
||||
nodeRoot = m_SettingsXML.CreateNode(XmlNodeType.Element, SETTINGSROOT, "");
|
||||
m_SettingsXML.AppendChild(nodeRoot);
|
||||
var dec = _SettingsXml.CreateXmlDeclaration("1.0", "utf-8", string.Empty);
|
||||
_SettingsXml.AppendChild(dec);
|
||||
|
||||
var nodeRoot = _SettingsXml.CreateNode(XmlNodeType.Element, SETTINGSROOT, "");
|
||||
_SettingsXml.AppendChild(nodeRoot);
|
||||
}
|
||||
}
|
||||
return m_SettingsXML;
|
||||
return _SettingsXml;
|
||||
}
|
||||
}
|
||||
|
||||
private string GetValue(SettingsProperty setting)
|
||||
{
|
||||
string ret = "";
|
||||
var ret = string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
if (IsRoaming(setting))
|
||||
{
|
||||
ret = SettingsXML.SelectSingleNode(SETTINGSROOT + "/" + setting.Name).InnerText;
|
||||
ret = SettingsXml.SelectSingleNode(SETTINGSROOT + "/" + setting.Name).InnerText;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = SettingsXML.SelectSingleNode(SETTINGSROOT + "/" + (new Microsoft.VisualBasic.Devices.Computer()).Name + "/" + setting.Name).InnerText;
|
||||
ret = SettingsXml.SelectSingleNode(SETTINGSROOT + "/" + Environment.MachineName + "/" + setting.Name).InnerText;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
if (!(setting.DefaultValue == null))
|
||||
{
|
||||
ret = setting.DefaultValue.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = "";
|
||||
}
|
||||
ret = setting.DefaultValue?.ToString() ?? "";
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -158,11 +149,11 @@ namespace mRemoteNG.Config.Settings.Providers
|
||||
{
|
||||
if (IsRoaming(propVal.Property))
|
||||
{
|
||||
SettingNode = (XmlElement) (SettingsXML.SelectSingleNode(SETTINGSROOT + "/" + propVal.Name));
|
||||
SettingNode = (XmlElement) (SettingsXml.SelectSingleNode(SETTINGSROOT + "/" + propVal.Name));
|
||||
}
|
||||
else
|
||||
{
|
||||
SettingNode = (XmlElement) (SettingsXML.SelectSingleNode(SETTINGSROOT + "/" + (new Microsoft.VisualBasic.Devices.Computer()).Name + "/" + propVal.Name));
|
||||
SettingNode = (XmlElement) (SettingsXml.SelectSingleNode(SETTINGSROOT + "/" + (new Microsoft.VisualBasic.Devices.Computer()).Name + "/" + propVal.Name));
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
@@ -183,12 +174,12 @@ namespace mRemoteNG.Config.Settings.Providers
|
||||
if (IsRoaming(propVal.Property))
|
||||
{
|
||||
//Store the value as an element of the Settings Root Node
|
||||
SettingNode = SettingsXML.CreateElement(propVal.Name);
|
||||
SettingNode = SettingsXml.CreateElement(propVal.Name);
|
||||
if (propVal.SerializedValue != null)
|
||||
{
|
||||
SettingNode.InnerText = propVal.SerializedValue.ToString();
|
||||
}
|
||||
SettingsXML.SelectSingleNode(SETTINGSROOT).AppendChild(SettingNode);
|
||||
SettingsXml.SelectSingleNode(SETTINGSROOT).AppendChild(SettingNode);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -196,21 +187,21 @@ namespace mRemoteNG.Config.Settings.Providers
|
||||
//creating a new machine name node if one doesnt exist.
|
||||
try
|
||||
{
|
||||
MachineNode = (XmlElement) (SettingsXML.SelectSingleNode(SETTINGSROOT + "/" + (new Microsoft.VisualBasic.Devices.Computer()).Name));
|
||||
MachineNode = (XmlElement) (SettingsXml.SelectSingleNode(SETTINGSROOT + "/" + (new Microsoft.VisualBasic.Devices.Computer()).Name));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MachineNode = SettingsXML.CreateElement((new Microsoft.VisualBasic.Devices.Computer()).Name);
|
||||
SettingsXML.SelectSingleNode(SETTINGSROOT).AppendChild(MachineNode);
|
||||
MachineNode = SettingsXml.CreateElement((new Microsoft.VisualBasic.Devices.Computer()).Name);
|
||||
SettingsXml.SelectSingleNode(SETTINGSROOT).AppendChild(MachineNode);
|
||||
}
|
||||
|
||||
if (MachineNode == null)
|
||||
{
|
||||
MachineNode = SettingsXML.CreateElement((new Microsoft.VisualBasic.Devices.Computer()).Name);
|
||||
SettingsXML.SelectSingleNode(SETTINGSROOT).AppendChild(MachineNode);
|
||||
MachineNode = SettingsXml.CreateElement((new Microsoft.VisualBasic.Devices.Computer()).Name);
|
||||
SettingsXml.SelectSingleNode(SETTINGSROOT).AppendChild(MachineNode);
|
||||
}
|
||||
|
||||
SettingNode = SettingsXML.CreateElement(propVal.Name);
|
||||
SettingNode = SettingsXml.CreateElement(propVal.Name);
|
||||
if (propVal.SerializedValue != null)
|
||||
{
|
||||
SettingNode.InnerText = propVal.SerializedValue.ToString();
|
||||
|
||||
@@ -10,6 +10,7 @@ using System.Globalization;
|
||||
using mRemoteNG.Themes;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.App.Info;
|
||||
using mRemoteNG.UI.Forms;
|
||||
using mRemoteNG.UI.Window;
|
||||
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ using mRemoteNG.App.Info;
|
||||
using mRemoteNG.Messages;
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.UI.Forms;
|
||||
|
||||
namespace mRemoteNG.Config.Settings
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@ using mRemoteNG.App;
|
||||
using System.Threading;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.Connection.Protocol.RDP;
|
||||
using mRemoteNG.UI.Forms;
|
||||
|
||||
|
||||
namespace mRemoteNG.Connection.Protocol.ICA
|
||||
|
||||
@@ -11,6 +11,7 @@ using mRemoteNG.Messages;
|
||||
using mRemoteNG.App;
|
||||
using MSTSCLib;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.UI.Forms;
|
||||
|
||||
|
||||
namespace mRemoteNG.Connection.Protocol.RDP
|
||||
|
||||
@@ -3,6 +3,7 @@ using Microsoft.VisualBasic;
|
||||
using mRemoteNG.App;
|
||||
using System.ComponentModel;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.UI.Forms;
|
||||
|
||||
|
||||
namespace mRemoteNG.Connection.Protocol.VNC
|
||||
@@ -245,8 +246,8 @@ namespace mRemoteNG.Connection.Protocol.VNC
|
||||
{
|
||||
_VNC.ConnectComplete += VNCEvent_Connected;
|
||||
_VNC.ConnectionLost += VNCEvent_Disconnected;
|
||||
mRemoteNG.frmMain.clipboardchange += VNCEvent_ClipboardChanged;
|
||||
if (!(((int)Force & (int)ConnectionInfo.Force.NoCredentials) == (int)ConnectionInfo.Force.NoCredentials) && !string.IsNullOrEmpty(Info.Password))
|
||||
frmMain.clipboardchange += VNCEvent_ClipboardChanged;
|
||||
if (((int)Force & (int)ConnectionInfo.Force.NoCredentials) != (int)ConnectionInfo.Force.NoCredentials && !string.IsNullOrEmpty(Info.Password))
|
||||
{
|
||||
_VNC.GetPassword = VNCEvent_Authenticate;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.Windows.Forms;
|
||||
using mRemoteNG.My;
|
||||
using mRemoteNG.UI.Window;
|
||||
using mRemoteNG.App;
|
||||
|
||||
using mRemoteNG.UI.Forms;
|
||||
|
||||
|
||||
namespace mRemoteNG.Messages
|
||||
|
||||
3
mRemoteV1/Properties/Application.Designer.cs
generated
3
mRemoteV1/Properties/Application.Designer.cs
generated
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using mRemoteNG.UI.Forms;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -40,7 +41,7 @@ namespace mRemoteNG.My
|
||||
[global::System.Diagnostics.DebuggerStepThroughAttribute()]
|
||||
protected override void OnCreateMainForm()
|
||||
{
|
||||
this.MainForm = mRemoteNG.frmMain.Default;
|
||||
this.MainForm = frmMain.Default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
2
mRemoteV1/Properties/Settings.Designer.cs
generated
2
mRemoteV1/Properties/Settings.Designer.cs
generated
@@ -13,7 +13,7 @@ namespace mRemoteNG.My {
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
internal sealed partial class Settings : System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using Microsoft.VisualBasic;
|
||||
using System.Collections;
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.UI.Forms;
|
||||
|
||||
|
||||
namespace mRemoteNG.Tools
|
||||
|
||||
2
mRemoteV1/UI/Forms/frmMain.Designer.cs
generated
2
mRemoteV1/UI/Forms/frmMain.Designer.cs
generated
@@ -1,4 +1,4 @@
|
||||
namespace mRemoteNG
|
||||
namespace mRemoteNG.UI.Forms
|
||||
{
|
||||
public partial class frmMain : System.Windows.Forms.Form
|
||||
{
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.Config;
|
||||
using mRemoteNG.My;
|
||||
using mRemoteNG.Themes;
|
||||
using PSTaskDialog;
|
||||
using SharedLibraryNG;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
@@ -12,18 +6,24 @@ using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.Config;
|
||||
using mRemoteNG.Config.KeyboardShortcuts;
|
||||
using mRemoteNG.Messages;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.UI.Window;
|
||||
using mRemoteNG.Config.Settings;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Controls;
|
||||
using mRemoteNG.Messages;
|
||||
using mRemoteNG.My;
|
||||
using mRemoteNG.Themes;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNG.UI.Window;
|
||||
using PSTaskDialog;
|
||||
using SharedLibraryNG;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
|
||||
namespace mRemoteNG
|
||||
namespace mRemoteNG.UI.Forms
|
||||
{
|
||||
public partial class frmMain
|
||||
{
|
||||
@@ -197,7 +197,7 @@ namespace mRemoteNG
|
||||
Runtime.LoadConnections();
|
||||
if (!Runtime.IsConnectionsFileLoaded)
|
||||
{
|
||||
System.Windows.Forms.Application.Exit();
|
||||
Application.Exit();
|
||||
return ;
|
||||
}
|
||||
Config.Putty.Sessions.StartWatcher();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using mRemoteNG.UI.Forms;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ using mRemoteNG.Config;
|
||||
using mRemoteNG.Connection.Protocol.VNC;
|
||||
using mRemoteNG.Connection.Protocol.RDP;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.UI.Forms;
|
||||
|
||||
namespace mRemoteNG.UI.Window
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Windows.Forms;
|
||||
using System.Text;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.UI.Forms;
|
||||
|
||||
|
||||
namespace mRemoteNG.UI.Window
|
||||
@@ -326,6 +327,7 @@ namespace mRemoteNG.UI.Window
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Windows.Forms;
|
||||
using mRemoteNG.App;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
using mRemoteNG.My;
|
||||
using mRemoteNG.UI.Forms;
|
||||
|
||||
|
||||
namespace mRemoteNG.UI.Window
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Windows.Forms;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
using mRemoteNG.App;
|
||||
using System.IO;
|
||||
using mRemoteNG.UI.Forms;
|
||||
|
||||
|
||||
namespace mRemoteNG.UI.Window
|
||||
|
||||
@@ -12,4 +12,7 @@
|
||||
<FallbackCulture>en-US</FallbackCulture>
|
||||
<VerifyUploadedFiles>false</VerifyUploadedFiles>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<EnableSecurityDebugging>false</EnableSecurityDebugging>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user