public AxMsRdpClient09Host(ProtocolServerBase protocolServer, double width = 0, double height = 0) : base(protocolServer, true) { InitializeComponent(); if (protocolServer.GetType() == typeof(ProtocolServerRDP)) { _rdpServer = (ProtocolServerRDP)protocolServer; _rdp = new AxMsRdpClient9NotSafeForScriptingEx(); ((System.ComponentModel.ISupportInitialize)(_rdp)).BeginInit(); _rdp.Dock = DockStyle.Fill; _rdp.Enabled = true; _rdp.BackColor = Color.Black; // set call back _rdp.OnRequestGoFullScreen += (sender, args) => { MakeNormal2FullScreen(); }; _rdp.OnRequestLeaveFullScreen += (sender, args) => { MakeFullScreen2Normal(); }; _rdp.OnRequestContainerMinimize += (sender, args) => { MakeForm2Minimize(); }; _rdp.OnDisconnected += RdpcOnDisconnected; _rdp.OnConfirmClose += RdpOnOnConfirmClose; _rdp.OnConnected += RdpOnOnConnected; _rdp.OnLoginComplete += RdpOnOnLoginComplete; ((System.ComponentModel.ISupportInitialize)(_rdp)).EndInit(); RdpHost.Child = _rdp; InitRdp(width, height); } else { _rdp = null; } }
public void ServerListRemove(ProtocolServerBase server) { Debug.Assert(server.Id > 0); if (Server.Delete(server.Id)) { ServerListUpdate(); } }
public VmServerEditorPage(ProtocolServerBase server, VmServerListPage host, bool isDuplicate = false) { Server = (ProtocolServerBase)server.Clone(); _isDuplicate = isDuplicate; if (_isDuplicate) { Server.Id = 0; } Host = host; IsAddMode = server.GetType() == typeof(ProtocolServerNone) || Server.Id == 0; // decrypt pwd if (Server.GetType() != typeof(ProtocolServerNone)) { SystemConfig.Instance.DataSecurity.DecryptPwd(Server); } var assembly = typeof(ProtocolServerBase).Assembly; var types = assembly.GetTypes(); // reflect remote protocols { ProtocolList.Clear(); ProtocolList = types.Where(item => item.IsSubclassOf(typeof(ProtocolServerBase)) && !item.IsAbstract) .Where(x => x.FullName != typeof(ProtocolServerNone).FullName) .Select(type => (ProtocolServerBase)Activator.CreateInstance(type)).ToList(); } // set selected protocol try { ProtocolSelected = ProtocolList.First(x => x.GetType() == Server.GetType()); } catch (Exception) { ProtocolSelected = ProtocolList.First(); } if (!IsAddMode) { ProtocolList.Clear(); ProtocolList.Add(ProtocolSelected); } else { if (string.IsNullOrEmpty(Server.GroupName)) { Server.GroupName = Host.SelectedGroup; } } Debug.Assert(Server.GetType() != typeof(ProtocolServerNone)); }
private static Server FromProtocolServerBase(ProtocolServerBase org) { var ret = new Server { Id = org.Id, Protocol = org.Protocol, ClassVersion = org.ClassVersion, JsonConfigString = org.ToJsonString() }; return(ret); }
public static int AddOrUpdate(ProtocolServerBase org, bool isAdd = false) { Init(); var tmp = (ProtocolServerBase)org.Clone(); tmp.SetNotifyPropertyChangedEnabled(false); SystemConfig.Instance.DataSecurity.EncryptInfo(tmp); if (isAdd == false) { var s = FromProtocolServerBase(tmp); return(s.Update() ? 1 : 0); } else { var s = FromProtocolServerBase(tmp); return(s.Insert()); } }
public ProtocolPuttyForm(ProtocolServerBase vm) : base() { InitializeComponent(); Vm = vm; DataContext = vm; GridUserName.Visibility = Visibility.Collapsed; GridPwd.Visibility = Visibility.Collapsed; SpSsh.Visibility = Visibility.Collapsed; GridPrivateKey.Visibility = Visibility.Collapsed; if (Vm.GetType() == typeof(ProtocolServerSSH) || Vm.GetType().BaseType == typeof(ProtocolServerWithAddrPortUserPwdBase)) { GridPrivateKey.Visibility = GridUserName.Visibility = GridPwd.Visibility = SpSsh.Visibility = Visibility.Visible; } if (Vm.GetType() == typeof(ProtocolServerTelnet) || Vm.GetType().BaseType == typeof(ProtocolServerWithAddrPortBase)) { } if (Vm.GetType() == typeof(ProtocolServerSSH)) { CbUsePrivateKey.IsChecked = false; if (!string.IsNullOrEmpty(((ProtocolServerSSH)Vm).PrivateKey)) { CbUsePrivateKey.IsChecked = true; } } }
public void ServerListUpdate(ProtocolServerBase protocolServer = null) { // read from db if (protocolServer == null) { ServerList.Clear(); foreach (var serverAbstract in PRM.Core.DB.Server.ListAllProtocolServerBase()) { ServerList.Add(serverAbstract); } } // edit else if (protocolServer.Id > 0 && ServerList.First(x => x.Id == protocolServer.Id) != null) { ServerList.First(x => x.Id == protocolServer.Id).Update(protocolServer); Server.AddOrUpdate(protocolServer); } // add else { Server.AddOrUpdate(protocolServer, true); ServerListUpdate(); } }
public ProtocolServerSSHForm(ProtocolServerBase vm) : base(vm) { }
public ProtocolServerRDPForm(ProtocolServerBase vm) { InitializeComponent(); Vm = (ProtocolServerRDP)vm; DataContext = vm; }
public ProtocolServerTelnetForm(ProtocolServerBase vm) : base(vm) { }