private void m_ConnectButton_Click( object sender, EventArgs e )
        {
            try
            {
                this.Enabled = false;

                // Trim spaces from copy-and-paste operations.
                m_ComputerComboBox.Text = m_ComputerComboBox.Text.Trim();
                m_AliasComboBox.Text = m_AliasComboBox.Text.Trim();

                var settings = new MstscSettings();
                settings.Computer = m_Presenter.BuildComputerName( m_ComputerComboBox.Text, m_AliasComboBox.Text );
                settings.Computer.AdminMode = m_LogoPictureBox.AdminMode;
                settings.AudioMode = m_AudioButton.AudioMode;
                settings.SharedDrives = m_DrivesButton.GetDrives();

                ThreadPool.QueueUserWorkItem( ( o ) => m_Presenter.MstscConnect( settings ) );

                // If we hide the window right away, sometimes it does not get removed from the taskbar.
                // To avoid this we wait a few secs before hiding the window.
                m_Timer.Enabled = true;
            }
            catch ( Exception ex )
            {
                m_Timer.Enabled = false;
                this.Enabled = true;
                Logger.LogException( ex );
                ShowErrorMessage( ex.ToString() );
            }
        }
示例#2
0
 private static string GetArgumentsString( MstscSettings settings )
 {
     string args = "/v:" + settings.Computer.Computer;
     if ( settings.Computer.AdminMode )
         args += " /console /admin";
     return args;
 }
示例#3
0
        public void Run( MstscSettings settings )
        {
            using ( var process = new Process() )
            {
                UpdateMstscConfig( settings );

                SetStartInfo( process.StartInfo, settings );
                process.Start();

                process.WaitForExit();
            }
        }
示例#4
0
 protected void SetStartInfo( ProcessStartInfo startInfo, MstscSettings settings )
 {
     if ( this.TestMode )
     {
         startInfo.FileName = "notepad.exe";
         startInfo.Arguments = "";
         Console.WriteLine( GetArgumentsString( settings ) );
     }
     else
     {
         startInfo.FileName = MstscExecutablePath;
         startInfo.Arguments = GetArgumentsString( settings );
     }
 }
        public void MstscAguments( )
        {
            var mstscApp = new TestMstscApp();
            ProcessStartInfo startInfo = new ProcessStartInfo();
            var settings = new MstscSettings();

            settings.Computer = new ComputerName( "chrismillerpc", null, false );
            mstscApp.SetStartInfo( startInfo, settings );
            Assert.AreEqual( "/v:chrismillerpc", startInfo.Arguments );

            settings.Computer = new ComputerName( "1.1.1.1", "work", true );
            mstscApp.SetStartInfo( startInfo, settings );
            Assert.AreEqual( "/v:1.1.1.1 /console /admin", startInfo.Arguments );

            mstscApp.TestMode = true;
            mstscApp.SetStartInfo( startInfo, settings );
            Assert.AreEqual( "notepad.exe", startInfo.FileName );
            Assert.AreEqual( "", startInfo.Arguments );
        }
示例#6
0
 private void UpdateMstscConfig( MstscSettings settings )
 {
     var config = MstscConfig.BuildMstscConfig();
     try
     {
         if ( this.TestMode )
         {
             var lines = File.ReadAllLines( MstscConfig.GetRdpConfigFilename() );
             var stream = new MemoryStream();
             config.Update( lines, settings, stream );
             var reader = new StreamReader( new MemoryStream( stream.ToArray() ) );
             Console.WriteLine( reader.ReadToEnd() );
         }
         else
             config.Update( settings );
     }
     catch ( Exception ex )
     {
         Logger.LogException( ex );
     }
     finally { config.Dispose(); }
 }
        public void MstscConnect( MstscSettings settings )
        {
            var mstscApp = new MstscApp();
            #if DEBUG
            mstscApp.TestMode = true;
            #endif
            try
            {
                mstscApp.Run( settings );
            }
            catch ( Exception ex )
            {
                Logger.LogException( ex );
            }

            OnMstscAppExited();

            // It is important to read before we write in case we have two instances of RemoteDesktopPlus open.
            // However RemoteDesktop doesn't have special logic for adding an IP address to the list like we
            // do so we need to do an integrate step.
            m_RecentComputerList = LoadRecentComputerList();

            // We use our own logic to determine what the recent computer list should be after a
            // connection was made.
            m_RecentComputerList.Push( settings.Computer );

            ComputerListFile serializer = new ComputerListFile();
            serializer.Write( m_RecentComputerList );

            OnComputerListUpdated();
        }
 public new void SetStartInfo( ProcessStartInfo startInfo, MstscSettings settings )
 {
     base.SetStartInfo( startInfo, settings );
 }
 public void Update( string[] inputLines, MstscSettings settings, Stream outputStream )
 {
     var dict = new Dictionary<string, string>( StringComparer.OrdinalIgnoreCase );
     SetUpdateDict( settings, dict );
     Update( inputLines, dict, outputStream );
 }
示例#10
0
 public void Update( string filePath, MstscSettings settings )
 {
     var dict = new Dictionary<string, string>( StringComparer.OrdinalIgnoreCase );
     SetUpdateDict( settings, dict );
     Update( filePath, dict );
 }
示例#11
0
 public void Update( MstscSettings settings )
 {
     Update( GetRdpConfigFilename(), settings );
 }
示例#12
0
 protected override void SetUpdateDict( MstscSettings settings, Dictionary<string, string> dict )
 {
     dict[AudioModeKey] = ((int) settings.AudioMode).ToString();
     dict[LastComputerKey] = settings.Computer.Computer;
     dict[SharedDrivesKey] = SerializeSharedDrives( settings.SharedDrives );
 }
示例#13
0
        protected override void SetUpdateDict( MstscSettings settings, Dictionary<string, string> dict )
        {
            // Get all the XP settings.
            base.SetUpdateDict( settings, dict );

            dict[SharedDrivesKey] = SerializeSharedDrives( settings.SharedDrives );
        }
示例#14
0
 protected virtual void SetUpdateDict( MstscSettings settings, Dictionary<string, string> dict )
 {
 }