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 );
     }
 }
예제 #5
0
        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();
        }
예제 #8
0
 public new void SetStartInfo( ProcessStartInfo startInfo, MstscSettings settings )
 {
     base.SetStartInfo( startInfo, settings );
 }
예제 #9
0
 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 )
 {
 }