public ConnectEventArgs(ConnectionHost host, ConnectionProtocol protocol) { TargetSystem = host; TargetProtocol = protocol; }
/// <summary> /// Load a connection for Edit-Mode /// </summary> /// <param name="connectionId"></param> /// <param name="connectionSettingId"></param> public void loadConnection(long connectionId, long connectionSettingId) { _EditConnectionId = connectionId; _EditConnectionSettingId = connectionSettingId; _ConnectionHostCache = StorageCore.Core.GetConnection(connectionId); _ConnectionProtocolCache = StorageCore.Core.GetConnectionSettings(connectionId).ToDictionary(p => p.getId()); _LastSelectedExistingProtocol = 0; if (_EditConnectionSettingId != 0 && _ConnectionOptionCache.Count == 0) //Only do this, if a Setting (=Protocol) is preselected and it is the first load { if (_ConnectionOptionCache.ContainsKey(connectionSettingId) == false) { _ConnectionOptionCache.Add(connectionSettingId, new Dictionary <string, object>()); } foreach (var cpo in StorageCore.Core.GetConnectionOptions(connectionSettingId)) { _ConnectionOptionCache[connectionSettingId].Add(cpo.getSettingname(), cpo.getSettingvalue()); } } // ## Load Connectiondata ## //Hostinformation if (connectionId != 0) { lblHostId.Content = "Hostinformation (ID: " + connectionId + ")"; } txtName.Text = _ConnectionHostCache.Name; txtHostname.Text = _ConnectionHostCache.Host; txtDescription.Text = _ConnectionHostCache.Description; ccbFolder.SelectedValue = new ImagedConnectionTreeViewItem(_ConnectionHostCache.Folder, ImagedConnectionTreeViewDatatype.Folder); chkPublic.IsChecked = _ConnectionHostCache.IsPublic; for (int i = 0; i < cmbOperatingSystem.Items.Count; i++) { if ((int)((ComboBoxItem)cmbOperatingSystem.Items[i]).Tag == _ConnectionHostCache.OS) { cmbOperatingSystem.SelectedIndex = i; break; } } //Protocolinformation foreach (ConnectionProtocol cp in _ConnectionProtocolCache.Values) { if (Kernel.GetAvailableProtocols().ContainsKey(cp.Protocol)) { var cmbi = new ComboBoxItem(); cmbi.Tag = cp.getId(); cmbi.Content = Kernel.GetAvailableProtocols()[cp.Protocol].GetProtocolName(); cmbExistingProtocols.Items.Add(cmbi); } } if (cmbExistingProtocols.Items.Count > 0) { cmbExistingProtocols.SelectedIndex = 0; } //Select the selected Protocol, if a protocol should be edited if (_EditConnectionSettingId != 0) { string protocolType = StorageCore.Core.GetConnectionSetting(_EditConnectionSettingId).Protocol; if (protocolType != null) { for (int i = 0; i < cmbExistingProtocols.Items.Count; i++) { if (((ComboBoxItem)cmbExistingProtocols.Items[i]).Tag.ToString() == protocolType) { cmbExistingProtocols.SelectedIndex = i; break; } } } cmbVpn.SelectedValue = _ConnectionHostCache.Vpn; } }
/// <summary> /// Get the Content of a Connection /// </summary> /// <param name="connectionId">ID of the connection</param> /// <returns></returns> private ImagedConnectionTreeViewItem getTreeViewConnectionItems(long connectionId) { ImagedConnectionTreeViewItem ret = new ImagedConnectionTreeViewItem(ImagedConnectionTreeViewDatatype.ConnectionHost); ret.Datatype = ImagedConnectionTreeViewDatatype.ConnectionHost; //This is a ConnectionHost ret.ID = connectionId; //The connectionId of this folder is the connectionId-Parameter //Get this Connection ConnectionHost thisConn = StorageCore.Core.GetConnection(connectionId); ret.Header = thisConn.Name; //This Displayname of this folder #region Determinate the Rights of this Connection if (thisConn.IsPublic == true && HidePublicFolder == false) //If the Connections is public and public connections are shown { if (thisConn.Owner == StorageCore.Core.GetUserId()) //Is the User also the owner? { ret.IsPrivate = ImagedConnectionTreeViewRight.PublicAndOwner; } else //User is not the owner { ret.IsPrivate = ImagedConnectionTreeViewRight.Public; } } else { ret.IsPrivate = ImagedConnectionTreeViewRight.Private; } #endregion #region Get containing Protocols List <ConnectionProtocol> protocols = StorageCore.Core.GetConnectionSettings(connectionId); if (_ShowProtocols == true) { foreach (ConnectionProtocol prot in protocols) { if (Kernel.GetAvailableProtocols().ContainsKey(prot.Protocol)) { ImagedConnectionTreeViewItem newProt = new ImagedConnectionTreeViewItem(ImagedConnectionTreeViewDatatype.ConnectionProtocol); //Get the Icon From Protocol newProt.Icon = Kernel.GetAvailableProtocols()[prot.Protocol].GetProtocolIcon(Core.ProtocolSystem.ProtocolBase.Declaration.IconType.SMALL); newProt.Datatype = ImagedConnectionTreeViewDatatype.ConnectionProtocol; newProt.ID = prot.Id; //Get the Displayname from Protocol newProt.Header = Kernel.GetAvailableProtocols()[prot.Protocol].GetProtocolName(); ret.Items.Add(newProt); } else { } } } #endregion #region Set Icon of the protocol used by this connection User userSettings = StorageCore.Core.GetUserSettings(); bool foundDefaultProtocol = false; //Determinate the default Connection that is used at a doubleclick and set the icon foreach (ConnectionProtocol prot in protocols) { if (prot.Protocol == userSettings.DefaultProtocol) { ret.Icon = Kernel.GetAvailableProtocols()[prot.Protocol].GetProtocolIcon(Core.ProtocolSystem.ProtocolBase.Declaration.IconType.SMALL); foundDefaultProtocol = true; break; } } if (foundDefaultProtocol == false) { if (protocols.Count > 0 && Kernel.GetAvailableProtocols().ContainsKey(protocols[0].Protocol)) { ret.Icon = Kernel.GetAvailableProtocols()[protocols[0].Protocol].GetProtocolIcon(Core.ProtocolSystem.ProtocolBase.Declaration.IconType.SMALL); } else { ret.Icon = new BitmapImage(new Uri("pack://application:,,,/beRemote.GUI;component/Images/screen16.png")); } } #endregion return(ret); }