public WinScpEncodedParameter() { string[] s = { "%", " ", "+", "/", "@", "\"", ":", ";" }; Transformation = val => OtherHelper.ReplaceU(s, val); Value = string.Empty; }
public void Run() { string rdpPath = Environment.ExpandEnvironmentVariables(_connection.GetEffectiveAppPath()); if (File.Exists(rdpPath)) { var parameters = _connection.Parameters.Where(p => p.DisplayName != "Размер экрана").ToList(); var outputFile = OtherHelper.ReplaceU(f, _connection.Name) + ".rdp"; var outputFolderParam = _connection.Parameters.FirstOrDefault(p => p.Name == "OutputFolder"); if (outputFolderParam != null && !string.IsNullOrEmpty(outputFolderParam.Value)) { Directory.CreateDirectory(outputFolderParam.Value); outputFile = Path.Combine(outputFolderParam.Value, outputFile); } TextWriter rdpFileWriter = new StreamWriter(path: outputFile); foreach (var p in parameters.Where(p => !(p is FolderPathConnectionParameter))) { var line = p.GetCommandLine(); if (string.IsNullOrEmpty(line)) { continue; } rdpFileWriter.Write(line); var delimiter = p.NextParameterDelimiter ?? _connection.ParameterDelimiter; rdpFileWriter.Write(delimiter); } var fullScreen = _connection.Parameters.FirstOrDefault(p => p.Name == "IsFullScreen") as SwitchConnectionParameter; if (fullScreen != null && !fullScreen.IsOn) { var size = _connection.Parameters.FirstOrDefault(p => p.Name == "ScreenSize").Value; string[] sizes = size.Split('x'); rdpFileWriter.WriteLine(sizes.Length == 2 ? "desktopwidth:i:" + sizes[0] : ""); rdpFileWriter.WriteLine(sizes.Length == 2 ? "desktopheight:i:" + sizes[1] : ""); } rdpFileWriter.Close(); Process myProc = new Process { StartInfo = { FileName = rdpPath, Arguments = $"\"{outputFile}\"", } }; myProc.Start(); } }
public void Run() { if (File.Exists(_connection.GetEffectiveAppPath())) { var hostParam = _connection.Parameters.First(p => p.Name == KnownParameters.Host); var portParam = _connection.Parameters.First(p => p.Name == KnownParameters.Port); var vncFilePath = OtherHelper.ReplaceU(f, _connection.Name) + ".vnc"; var vncOutPathParam = _connection.Parameters.First(p => p.Name == "OutputFolder"); if (vncOutPathParam != null && !string.IsNullOrEmpty(vncOutPathParam.Value)) { Directory.CreateDirectory(vncOutPathParam.Value); vncFilePath = Path.Combine(vncOutPathParam.Value, vncFilePath); } TextWriter vncFile = new StreamWriter(vncFilePath); vncFile.WriteLine("[Connection]"); vncFile.WriteLine(hostParam.GetCommandLine()); vncFile.WriteLine(portParam.GetCommandLine()); var userParam = _connection.Parameters.First(p => p.Name == KnownParameters.User); vncFile.WriteLine(userParam.GetCommandLine()); var passParam = _connection.Parameters.First(p => p.Name == KnownParameters.Password); vncFile.WriteLine(passParam.GetCommandLine()); vncFile.WriteLine("[Options]"); var fullScreenParam = _connection.Parameters.First(p => p.Name == "IsFullScreen"); vncFile.WriteLine(fullScreenParam.GetCommandLine()); var viewOnly = _connection.Parameters.First(p => p.Name == "ViewOnly"); vncFile.WriteLine(viewOnly.GetCommandLine()); vncFile.WriteLine(passParam.Value != "" && passParam.Value.Length > 8 ? "protocol3.3=1" : ""); // f****n vnc 4.0 auth vncFile.Close(); Process myProc = new Process { StartInfo = { FileName = _connection.GetEffectiveAppPath(), Arguments = "-config \"" + vncFilePath } }; myProc.Start(); } }