public MonitorParametersWindow(MonitorParameters initialValues = null)
 {
     InitializeComponent();
     if (initialValues != null)
     {
         TextBoxPath.Text = initialValues.Path;
         TextBoxHost.Text = initialValues.Host;
         TextBoxPort.Text = initialValues.Port;
     }
 }
        private MonitorParameters ShowMonitorParametersWindow(MonitorParameters initialParameters)
        {
            var documentationControl = new MonitorParametersWindow(initialParameters);
            var ok = documentationControl.ShowDialog();

            if (ok.HasValue && ok.Value)
            {
                return(new MonitorParameters
                {
                    Host = documentationControl.Host,
                    Path = documentationControl.Path,
                    Port = documentationControl.Port
                });
            }

            return(null);
        }
        private MonitorParameters GetSavedParameters()
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            var parameters = new MonitorParameters()
            {
                Path = Settings.Default.Path,
                Host = Settings.Default.Host,
                Port = Settings.Default.Port,
            };

            if (string.IsNullOrEmpty(parameters.Path))
            {
                var dte = (DTE)this.ServiceProvider?.GetServiceAsync(typeof(DTE))?.Result;
                if (!string.IsNullOrEmpty(dte?.Solution?.FullName))
                {
                    string solutionDir = System.IO.Path.GetDirectoryName(dte.Solution.FullName);
                    parameters.Path = solutionDir;
                }
                else
                {
                    parameters.Path = Environment.CurrentDirectory;
                }
            }

            if (string.IsNullOrEmpty(parameters.Host))
            {
                parameters.Host = Monitor.GetDefaultPrivateNetworkIp();
            }

            if (string.IsNullOrEmpty(parameters.Port))
            {
                parameters.Port = "5500";
            }

            return(parameters);
        }