private void TerminalServerManager_Load(object sender, EventArgs e) { // This prevents SharpDevelop and Visual Studio from both an exception in design mode for controls using this HistoryTreeView and from crashing when opening the // designer for this class. if (LicenseManager.UsageMode == LicenseUsageMode.Designtime) { return; } if (this.DesignMode) { return; } this.ServerNameComboBox.Items.Clear(); FavoriteConfigurationElementCollection favorites = Settings.GetFavorites(SaveInDB); if (favorites != null) { foreach (FavoriteConfigurationElement elm in favorites) { if (typeof(RDPConnection).IsEqual(elm.Protocol)) { this.ServerNameComboBox.Items.Add(elm.ServerName); } } } }
public static FavoriteConfigurationElement GetOrCreateQuickConnectFavorite(String server, Boolean ConnectToConsole, Int32 port, string protocol, string url, bool isDatabaseFavorite) { FavoriteConfigurationElementCollection favorites = Settings.GetFavorites(isDatabaseFavorite); FavoriteConfigurationElement favorite = favorites[server]; if (favorite != null) { favorite.ConnectToConsole = ConnectToConsole; } else //create a temporaty favorite and connect to it { favorite = new FavoriteConfigurationElement(); favorite.ConnectToConsole = ConnectToConsole; favorite.ServerName = server; favorite.Name = server; favorite.Protocol = protocol; if (!string.IsNullOrEmpty(url)) { favorite.Url = url; } if (port != 0) { favorite.Port = port; } } return(favorite); }
public static FavoriteConfigurationElement GetFavoriteUpdatedCopy(String connectionName, Boolean forceConsole, Boolean forceNewWindow, CredentialSet credential, bool isDatabaseFavorite) { FavoriteConfigurationElementCollection favorites = Settings.GetFavorites(isDatabaseFavorite); FavoriteConfigurationElement favorite = favorites[connectionName]; if (favorite == null) { return(null); } favorite = (FavoriteConfigurationElement)favorite.Clone(); if (forceConsole) { favorite.ConnectToConsole = true; } if (forceNewWindow) { favorite.NewWindow = true; } if (credential != null) { favorite.XmlCredentialSetName = credential.Name; favorite.UserName = credential.Username; favorite.DomainName = credential.Domain; favorite.EncryptedPassword = credential.Password; } return(favorite); }
internal void RemoveDefaultFavorite() { FavoriteConfigurationElementCollection defaultFav = GetSection().DefaultFavorite; defaultFav.Clear(); SaveImmediatelyIfRequested(); }
public static FavoriteConfigurationElementCollection GetFavorites(bool isDatabaseFavorite) { if (!isDatabaseFavorite) { TerminalsConfigurationSection section = GetSection(); if (section != null) { return(section.Favorites); } } else { FavoriteConfigurationElementCollection collection = new FavoriteConfigurationElementCollection(); using (TerminalsObjectContext dc = TerminalsObjectContext.Create()) { if (dc == null) { return(null); } foreach (var connection in dc.Connections) { FavoriteConfigurationElement favorite = connection.ToFavorite(); collection.Add(favorite); } } return(collection); } return(null); }
private List <FavoriteConfigurationElement> GetConflictingFavorites( List <FavoriteConfigurationElement> favorites) { FavoriteConfigurationElementCollection savedFavorites = Settings.GetFavorites(SaveInDB); return(favorites.Where(favorite => savedFavorites[favorite.Name] != null).ToList()); }
public static void SaveDefaultFavorite(FavoriteConfigurationElement favorite) { FavoriteConfigurationElementCollection defaultFav = GetSection().DefaultFavorite; defaultFav.Clear(); defaultFav.Add(favorite); SaveImmediatelyIfRequested(); }
private void RenameConflictingFavorites(List <FavoriteConfigurationElement> conflictingFavorites) { FavoriteConfigurationElementCollection savedFavorites = Settings.GetFavorites(SaveInDB); foreach (FavoriteConfigurationElement favoriteToRename in conflictingFavorites) { this.AddImportSuffixToFavorite(favoriteToRename, savedFavorites); } }
private void AddImportSuffixToFavorite(FavoriteConfigurationElement favoriteToRename, FavoriteConfigurationElementCollection savedFavorites) { favoriteToRename.Name += importSuffix; if (savedFavorites[favoriteToRename.Name] != null) { this.AddImportSuffixToFavorite(favoriteToRename, savedFavorites); } }
private void CreateFavoriteButtons() { FavoriteConfigurationElementCollection favorites = Settings.GetFavorites(false); foreach (string favoriteName in Settings.FavoritesToolbarButtons) { this.CreateFavoriteButton(favorites, favoriteName); } }
private static void ReCreateAllTags(bool isDatabaseFavorite) { FavoriteConfigurationElementCollection favorites = GetFavorites(isDatabaseFavorite); foreach (FavoriteConfigurationElement favorite in favorites) { // dont report update here AddTagsToSettings(favorite.TagList, favorite.IsDatabaseFavorite); } }
public AddConnectionForm(bool saveInDB) { this.InitializeComponent(); FavoriteConfigurationElementCollection favorites = Settings.GetFavorites(saveInDB); foreach (FavoriteConfigurationElement favorite in favorites) { this.lvFavorites.Items.Add(favorite.Name); } }
private void CreateFavoriteButton(FavoriteConfigurationElementCollection favorites, string favoriteName) { FavoriteConfigurationElement favorite = favorites[favoriteName]; if (favorite != null) { ToolStripButton favoriteBtn = this.CreateFavoriteButton(favorite); this.favoriteToolBar.Items.Add(favoriteBtn); } }
private static void UpdateObsoleteConfigVersions() { if (Settings.ConfigVersion != null && Settings.ConfigVersion <= new Version(4, 0, 0, 1)) { Log.Info("Upgrading configuration to version level 4.0.0.2."); FavoriteConfigurationElementCollection favorites = Settings.GetFavorites(false); foreach (FavoriteConfigurationElement favorite in favorites) { switch (favorite.Url) { case "http://": case "https://": favorite.Url = null; break; } if (favorite.ToolBarIcon.StartsWith(@"C:\Kohl\Terminals-bin\")) { favorite.ToolBarIcon = favorite.ToolBarIcon.Replace(@"C:\Kohl\Terminals-bin\", string.Empty); } } // The changes need to be saved. Settings.SaveAndFinishDelayedUpdate(); } if (Settings.ConfigVersion != null && Settings.ConfigVersion <= new Version(4, 0, 0, 3)) { Log.Info("Fixing configuration to match new version " + AssemblyInfo.Version.ToString() + "."); string newConfig = null; using (FileStream fs = new FileStream(Settings.ConfigurationFileLocation, FileMode.Open, FileAccess.Read, FileShare.ReadWrite & FileShare.Delete)) { using (StreamReader stream = new StreamReader(fs)) { newConfig = stream.ReadToEnd(); } } newConfig = newConfig .Replace( @"<?xml version=""1.0"" encoding=""utf-8"" ?> <configuration>", @"<?xml version=""1.0"" encoding=""utf-8"" ?> <!-- Written by Oliver Kohl D.Sc. --> <configuration>"); // Save the new configuration file. SaveConfigurationFile(newConfig); } }
private static SortableList <FavoriteConfigurationElement> SelectFavoritesFromHistoryItems(SortableList <HistoryItem> groupedByDate) { FavoriteConfigurationElementCollection favorites = Settings.GetFavorites(false); SortableList <FavoriteConfigurationElement> selection = new SortableList <FavoriteConfigurationElement>(); foreach (HistoryItem favoriteTouch in groupedByDate) { FavoriteConfigurationElement favorite = favorites[favoriteTouch.Name]; if (favorite != null && !selection.Contains(favorite)) { selection.Add(favorite); } } return(selection); }
/// <summary> /// Gets all favorites, which contain required tag in not sorted collection. /// If, the tag is empty, than returns "Untagged" favorites. /// </summary> private static List <FavoriteConfigurationElement> GetFavoritesByTag(String tag, bool isDatabaseFavorite) { FavoriteConfigurationElementCollection result = GetFavorites(isDatabaseFavorite); if (result == null) { return(new List <FavoriteConfigurationElement>()); } if (String.IsNullOrEmpty(tag) || tag == UNTAGGED_NODENAME) { return(result.ToList() .Where(favorite => String.IsNullOrEmpty(favorite.Tags)) .ToList()); } return(result.ToList() .Where(favorite => favorite.TagList.Contains(tag, StringComparer.CurrentCultureIgnoreCase)) .ToList()); }
FavoriteConfigurationElementCollection IImport.ImportFavorites(string Filename) { FavoriteConfigurationElementCollection coll = new FavoriteConfigurationElementCollection(); if(System.IO.File.Exists(Filename)) { FavoriteConfigurationElement fav = null; string[] lines = System.IO.File.ReadAllLines(Filename); foreach(string line in lines) { if(line.StartsWith("[") && line.EndsWith("]")) { if(fav == null) { fav = new FavoriteConfigurationElement(); fav.Name = line.Substring(1, line.Length - 2); } else { coll.Add(fav); fav = new FavoriteConfigurationElement(); } } else { if(line == "") { coll.Add(fav); fav = new FavoriteConfigurationElement(); } else { string propertyName = line.Substring(0, line.IndexOf("=")); string pValue = line.Substring(line.IndexOf("=") + 1); switch(propertyName) { case "ServerName": fav.ServerName = pValue; break; case "Port": int p = 3389; int.TryParse(pValue, out p); fav.Port = p; break; case "Username": fav.UserName = pValue; break; case "Domain": fav.DomainName = pValue; break; case "Comment": break; case "Password": break; case "DesktopWidth": fav.DesktopSize = DesktopSize.AutoScale; break; case "DesktopHeight": fav.DesktopSize = DesktopSize.AutoScale; break; case "ColorDepth": switch(pValue) { case "8": fav.Colors = Colors.Bits8; break; case "16": fav.Colors = Colors.Bit16; break; case "24": fav.Colors = Colors.Bits24; break; case "32": fav.Colors = Colors.Bits32; break; default: fav.Colors = Colors.Bit16; break; } break; case "UseSmartSizing": if(pValue == "1") fav.DesktopSize = DesktopSize.AutoScale; break; case "FullScreenMonitor": if(pValue == "1") fav.DesktopSize = DesktopSize.FullScreen; break; case "ConsoleConnection": fav.ConnectToConsole = false; if(pValue == "1") fav.ConnectToConsole = true; break; case "UseCompression": break; case "BitmapPersistence": break; case "DisableWallpaper": fav.DisableWallPaper = false; if(pValue == "1") fav.DisableWallPaper = true; break; case "DisableFullWindowDrag": break; case "DisableMenuAnimations": break; case "DisableTheming": break; case "DisableCursorShadow": break; case "DisableCursorSettings": break; case "RedirectSmartCards": fav.RedirectSmartCards = false; if(pValue == "1") fav.RedirectSmartCards = true; break; case "RedirectDrives": fav.RedirectDrives = false; if(pValue == "1") fav.RedirectDrives = true; break; case "RedirectPorts": fav.RedirectPorts = false; if(pValue == "1") fav.RedirectPorts = true; break; case "RedirectPrinters": fav.RedirectPrinters = false; if(pValue == "1") fav.RedirectPrinters = true; break; case "EnableWindowsKey": break; case "KeyboardHookMode": break; case "AudioRedirectionMode": if(pValue == "0") fav.Sounds = RemoteSounds.Redirect; if(pValue == "1") fav.Sounds = RemoteSounds.PlayOnServer; if(pValue == "2") fav.Sounds = RemoteSounds.DontPlay; break; case "AlternateShell": break; case "ShellWorkingDir": break; case "AuthenticationLevel": break; default: break; } } } } } return coll; }
FavoriteConfigurationElementCollection IImport.ImportFavorites(string Filename) { FavoriteConfigurationElementCollection coll = new FavoriteConfigurationElementCollection(); if (System.IO.File.Exists(Filename)) { FavoriteConfigurationElement fav = null; string[] lines = System.IO.File.ReadAllLines(Filename); foreach (string line in lines) { if (line.StartsWith("[") && line.EndsWith("]")) { if (fav == null) { fav = new FavoriteConfigurationElement(); fav.Name = line.Substring(1, line.Length - 2); } else { coll.Add(fav); fav = new FavoriteConfigurationElement(); } } else { if (line == "") { coll.Add(fav); fav = new FavoriteConfigurationElement(); } else { string propertyName = line.Substring(0, line.IndexOf("=")); string pValue = line.Substring(line.IndexOf("=") + 1); switch (propertyName) { case "ServerName": fav.ServerName = pValue; break; case "Port": int p = 3389; int.TryParse(pValue, out p); fav.Port = p; break; case "Username": fav.UserName = pValue; break; case "Domain": fav.DomainName = pValue; break; case "Comment": break; case "Password": break; case "DesktopWidth": fav.DesktopSize = DesktopSize.AutoScale; break; case "DesktopHeight": fav.DesktopSize = DesktopSize.AutoScale; break; case "ColorDepth": switch (pValue) { case "8": fav.Colors = Colors.Bits8; break; case "16": fav.Colors = Colors.Bit16; break; case "24": fav.Colors = Colors.Bits24; break; case "32": fav.Colors = Colors.Bits32; break; default: fav.Colors = Colors.Bit16; break; } break; case "UseSmartSizing": if (pValue == "1") { fav.DesktopSize = DesktopSize.AutoScale; } break; case "FullScreenMonitor": if (pValue == "1") { fav.DesktopSize = DesktopSize.FullScreen; } break; case "ConsoleConnection": fav.ConnectToConsole = false; if (pValue == "1") { fav.ConnectToConsole = true; } break; case "UseCompression": break; case "BitmapPersistence": break; case "DisableWallpaper": fav.DisableWallPaper = false; if (pValue == "1") { fav.DisableWallPaper = true; } break; case "DisableFullWindowDrag": break; case "DisableMenuAnimations": break; case "DisableTheming": break; case "DisableCursorShadow": break; case "DisableCursorSettings": break; case "RedirectSmartCards": fav.RedirectSmartCards = false; if (pValue == "1") { fav.RedirectSmartCards = true; } break; case "RedirectDrives": fav.RedirectDrives = false; if (pValue == "1") { fav.RedirectDrives = true; } break; case "RedirectPorts": fav.RedirectPorts = false; if (pValue == "1") { fav.RedirectPorts = true; } break; case "RedirectPrinters": fav.RedirectPrinters = false; if (pValue == "1") { fav.RedirectPrinters = true; } break; case "EnableWindowsKey": break; case "KeyboardHookMode": break; case "AudioRedirectionMode": if (pValue == "0") { fav.Sounds = RemoteSounds.Redirect; } if (pValue == "1") { fav.Sounds = RemoteSounds.PlayOnServer; } if (pValue == "2") { fav.Sounds = RemoteSounds.DontPlay; } break; case "AlternateShell": break; case "ShellWorkingDir": break; case "AuthenticationLevel": break; default: break; } } } } } return(coll); }
FavoriteConfigurationElementCollection IImport.ImportFavorites(string Filename) { string name = System.IO.Path.GetFileName(Filename).Replace(System.IO.Path.GetExtension(Filename), ""); FavoriteConfigurationElementCollection coll = new FavoriteConfigurationElementCollection(); if (System.IO.File.Exists(Filename)) { FavoriteConfigurationElement fav = null; string[] lines = System.IO.File.ReadAllLines(Filename); fav = new FavoriteConfigurationElement(); fav.Name = name; coll.Add(fav); foreach (string line in lines) { string propertyName = line.Substring(0, line.IndexOf(":")); string pValue = line.Substring(line.LastIndexOf(":") + 1); switch (propertyName) { case "full address": fav.ServerName = pValue; break; case "server port": int p = 3389; int.TryParse(pValue, out p); fav.Port = p; break; case "username": fav.UserName = pValue; break; case "domain": fav.DomainName = pValue; break; case "session bpp": switch (pValue) { case "8": fav.Colors = Colors.Bits8; break; case "16": fav.Colors = Colors.Bit16; break; case "24": fav.Colors = Colors.Bits24; break; case "32": fav.Colors = Colors.Bits32; break; default: fav.Colors = Colors.Bit16; break; } break; case "screen mode id": fav.DesktopSize = DesktopSize.AutoScale; if (pValue == "1") { fav.DesktopSize = DesktopSize.FullScreen; } break; case "connect to console": fav.ConnectToConsole = false; if (pValue == "1") { fav.ConnectToConsole = true; } break; case "disable wallpaper": fav.DisableWallPaper = false; if (pValue == "1") { fav.DisableWallPaper = true; } break; case "redirectsmartcards": fav.RedirectSmartCards = false; if (pValue == "1") { fav.RedirectSmartCards = true; } break; case "redirectdrives": fav.RedirectDrives = false; if (pValue == "1") { fav.RedirectDrives = true; } break; case "redirectcomports": fav.RedirectPorts = false; if (pValue == "1") { fav.RedirectPorts = true; } break; case "redirectprinters": fav.RedirectPrinters = false; if (pValue == "1") { fav.RedirectPrinters = true; } break; case "audiomode": if (pValue == "0") { fav.Sounds = RemoteSounds.Redirect; } if (pValue == "1") { fav.Sounds = RemoteSounds.PlayOnServer; } if (pValue == "2") { fav.Sounds = RemoteSounds.DontPlay; } break; default: break; } } } return(coll); }
public FavoriteConfigurationElementCollection ImportFavorites(string Filename) { FavoriteConfigurationElementCollection fav = null; InputBoxResult result = InputBox.Show("Password", "vRD Password", '*'); if (result.ReturnCode == System.Windows.Forms.DialogResult.OK) { byte[] file = System.IO.File.ReadAllBytes(Filename); string xml = ImportvRD.a(file, result.Text).Replace(" encoding=\"utf-16\"", ""); byte[] data = System.Text.ASCIIEncoding.Default.GetBytes(xml); using (System.IO.MemoryStream sw = new MemoryStream(data)) { if (sw.Position > 0 & sw.CanSeek) { sw.Seek(0, SeekOrigin.Begin); } System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(typeof(vRdImport.vRDConfigurationFile)); object results = x.Deserialize(sw); List <vRdImport.Connection> connections = new List <vRdImport.Connection>(); List <vRdImport.vRDConfigurationFileConnectionsFolder> folders = new List <vRdImport.vRDConfigurationFileConnectionsFolder>(); Dictionary <string, vRdImport.vRDConfigurationFileCredentialsFolderCredentials> credentials = new Dictionary <string, vRdImport.vRDConfigurationFileCredentialsFolderCredentials>(); if (results != null) { vRdImport.vRDConfigurationFile config = (results as vRdImport.vRDConfigurationFile); if (config != null) { //scan in all credentials into a dictionary foreach (object item in config.Items) { if (item is vRdImport.vRDConfigurationFileCredentialsFolder) { vRdImport.vRDConfigurationFileCredentialsFolder credentialFolder = (item as vRdImport.vRDConfigurationFileCredentialsFolder); if (credentialFolder != null) { foreach (vRdImport.vRDConfigurationFileCredentialsFolderCredentials cred in credentialFolder.Credentials) { credentials.Add(cred.Guid, cred); } } } if (item is vRdImport.vRDConfigurationFileCredentialsFolderCredentials) { vRdImport.vRDConfigurationFileCredentialsFolderCredentials cred = (item as vRdImport.vRDConfigurationFileCredentialsFolderCredentials); credentials.Add(cred.Guid, cred); } } //scan in the connections, and recurse folders foreach (object item in config.Items) { if (item is vRdImport.Connection) { vRdImport.Connection connection = (item as vRdImport.Connection); if (connection != null) { connections.Add(connection); } } else if (item is vRdImport.vRDConfigurationFileConnectionsFolder) { vRdImport.vRDConfigurationFileConnectionsFolder folder = (item as vRdImport.vRDConfigurationFileConnectionsFolder); if (folder != null) { folders.Add(folder); } } } } } string f = ""; } } return(fav); }
FavoriteConfigurationElementCollection IImport.ImportFavorites(string Filename) { string name = System.IO.Path.GetFileName(Filename).Replace(System.IO.Path.GetExtension(Filename),""); FavoriteConfigurationElementCollection coll = new FavoriteConfigurationElementCollection(); if(System.IO.File.Exists(Filename)) { FavoriteConfigurationElement fav = null; string[] lines = System.IO.File.ReadAllLines(Filename); fav = new FavoriteConfigurationElement(); fav.Name = name; coll.Add(fav); foreach(string line in lines) { string propertyName = line.Substring(0, line.IndexOf(":")); string pValue = line.Substring(line.LastIndexOf(":") + 1); switch(propertyName) { case "full address": fav.ServerName = pValue; break; case "server port": int p = 3389; int.TryParse(pValue, out p); fav.Port = p; break; case "username": fav.UserName = pValue; break; case "domain": fav.DomainName = pValue; break; case "session bpp": switch(pValue) { case "8": fav.Colors = Colors.Bits8; break; case "16": fav.Colors = Colors.Bit16; break; case "24": fav.Colors = Colors.Bits24; break; case "32": fav.Colors = Colors.Bits32; break; default: fav.Colors = Colors.Bit16; break; } break; case "screen mode id": fav.DesktopSize = DesktopSize.AutoScale; if(pValue == "1") fav.DesktopSize = DesktopSize.FullScreen; break; case "connect to console": fav.ConnectToConsole = false; if(pValue == "1") fav.ConnectToConsole = true; break; case "disable wallpaper": fav.DisableWallPaper = false; if(pValue == "1") fav.DisableWallPaper = true; break; case "redirectsmartcards": fav.RedirectSmartCards = false; if(pValue == "1") fav.RedirectSmartCards = true; break; case "redirectdrives": fav.RedirectDrives = false; if(pValue == "1") fav.RedirectDrives = true; break; case "redirectcomports": fav.RedirectPorts = false; if(pValue == "1") fav.RedirectPorts = true; break; case "redirectprinters": fav.RedirectPrinters = false; if(pValue == "1") fav.RedirectPrinters = true; break; case "audiomode": if(pValue == "0") fav.Sounds = RemoteSounds.Redirect; if(pValue == "1") fav.Sounds = RemoteSounds.PlayOnServer; if(pValue == "2") fav.Sounds = RemoteSounds.DontPlay; break; default: break; } } } return coll; }