//********************************************************************************************** public Server Copy(ServerType newType) { //How the hell can i use MemberwiseClone while changing type?!? //Server copy = (Server)MemberwiseClone(); //Oh well, i will just copy the members //it may be betters since i need to make changes //to the values when converting between types Server copy = Server.GetServerInstance(newType); copy.IsFavorite = false; copy.Name = Name; copy.Host = Host; copy.Username = Username; copy.Password = Password; copy.SendKeys = SendKeys; copy.UseSound = UseSound; copy.ConnectDrives = ConnectDrives; copy.GroupID = GroupID; copy.Color = Color; copy.Width = Width; copy.Height = Height; copy.AutoScale = AutoScale; copy.SSH1 = SSH1; copy.Passive = Passive; copy.Themes = Themes; copy.Certificates = Certificates; copy.Encryption = Encryption; copy.UseHtmlLogin = UseHtmlLogin; copy.HtmlUserBox = HtmlUserBox; copy.HtmlPassBox = HtmlPassBox; copy.HtmlLoginBtn = HtmlLoginBtn; copy.TabColor = TabColor; copy.Notes = Notes; copy.SshTerminal = SshTerminal; copy.SshKey = SshKey; copy.FtpDataType = FtpDataType; //don't copy the port, use the protocols default copy.Port = GetDefaultServerPort(newType); return(copy); }
//************************************************************************************************** private void LoadServers() { Main.servers.Clear(); using (XwDbCommand sql = new XwDbCommand(Config.GetConnectionString(), "Data.SQLite")) { sql.ExecuteTX($@"SELECT id ,name ,host ,ServerType ,Username ,Password ,port ,Sendkeys ,sound ,drives ,favorite ,groupid ,color ,X ,Y ,Console ,AutoScale ,SSH1 ,Passive ,Themes ,Certificates ,UseHtmlLogin ,HtmlUserBox ,HtmlPassBox ,HtmlLoginBtn ,TabColor ,Notes ,SshTerminal ,Encryption ,SshKey FROM Servers ORDER BY name COLLATE NOCASE"); while (sql.Read()) { ServerType type = (ServerType)sql.Value("ServerType").ToInt32(); var server = Server.GetServerInstance(type); server.ID = sql.Value("id").ToInt32(); server.Type = type; server.Name = sql.Value("name").ToString(); server.Host = sql.Value("host").ToString(); server.Username = sql.Value("username").ToString(); server.Password = sql.Value("password").ToString(); server.Port = sql.Value("port").ToInt32(); server.SendKeys = sql.Value("sendkeys").ToBoolean(); server.UseSound = sql.Value("sound").ToBoolean(); server.ConnectDrives = sql.Value("drives").ToBoolean(); server.IsFavorite = sql.Value("favorite").ToBoolean(); server.GroupID = sql.Value("GroupID").ToInt32(); server.Color = sql.Value("Color").ToInt32(); server.Width = sql.Value("X").ToInt32(); server.Height = sql.Value("Y").ToInt32(); server.Console = sql.Value("Console").ToBoolean(); server.AutoScale = sql.Value("AutoScale").ToBoolean(); server.SSH1 = sql.Value("SSH1").ToBoolean(); server.Passive = sql.Value("Passive").ToBoolean(); server.Themes = sql.Value("Themes").ToBoolean(); server.Certificates = sql.Value("Certificates").ToBoolean(); server.UseHtmlLogin = sql.Value("UseHtmlLogin").ToBoolean(); server.HtmlUserBox = sql.Value("HtmlUserBox").ToString(); server.HtmlPassBox = sql.Value("HtmlPassBox").ToString(); server.HtmlLoginBtn = sql.Value("HtmlLoginBtn").ToString(); server.TabColor = sql.Value("TabColor").ToInt32(); server.Notes = sql.Value("Notes").ToString(); server.SshTerminal = sql.Value("SshTerminal").ToInt32(); server.Encryption = sql.Value("Encryption").ToBoolean(); server.SshKey = sql.Value("SshKey").ToString(); Main.servers.Add(server); } } }