private void Connections_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            _selectedConn = (CrmConn)Connections.SelectedItem;
            if (_selectedConn != null)
            {
                Connect.IsEnabled = !string.IsNullOrEmpty(_selectedConn.Name);
                Delete.IsEnabled = !string.IsNullOrEmpty(_selectedConn.Name);
                ModifyConnection.IsEnabled = !string.IsNullOrEmpty(_selectedConn.Name);

                if (_connectionAdded)
                    _connectionAdded = false;
                else
                    UpdateSelectedConnection(false);
            }
            else
            {
                Connect.IsEnabled = false;
                Delete.IsEnabled = false;
                ModifyConnection.IsEnabled = false;
            }

            Publish.IsEnabled = false;
            Customizations.IsEnabled = false;
            Solutions.IsEnabled = false;
            Assemblies.IsEnabled = false;
        }
        private void GetConnections()
        {
            Connections.ItemsSource = null;

            var path = Path.GetDirectoryName(_selectedProject.FullName);
            XmlDocument doc = new XmlDocument();

            if (!ConfigFileExists(_selectedProject))
            {
                _logger.WriteToOutputWindow("Error Retrieving Connections From Config File: Missing CRMDeveloperExtensions.config file", Logger.MessageType.Error);
                return;
            }

            doc.Load(path + "\\CRMDeveloperExtensions.config");
            XmlNodeList connections = doc.GetElementsByTagName("Connection");
            if (connections.Count == 0) return;

            List<CrmConn> crmConnections = new List<CrmConn>();

            foreach (XmlNode node in connections)
            {
                CrmConn conn = new CrmConn();
                XmlNode nameNode = node["Name"];
                if (nameNode != null)
                    conn.Name = nameNode.InnerText;
                XmlNode connectionStringNode = node["ConnectionString"];
                if (connectionStringNode != null)
                    conn.ConnectionString = DecodeString(connectionStringNode.InnerText);
                XmlNode orgIdNode = node["OrgId"];
                if (orgIdNode != null)
                    conn.OrgId = orgIdNode.InnerText;
                XmlNode versionNode = node["Version"];
                if (versionNode != null)
                    conn.Version = versionNode.InnerText;

                crmConnections.Add(conn);
            }

            Connections.ItemsSource = crmConnections;

            if (Connections.SelectedIndex == -1 && crmConnections.Count > 0)
                Connections.SelectedIndex = 0;
        }
        private CrmConn GetSelectedConnection(Project project)
        {
            CrmConn selectedConnection = new CrmConn();
            var projectPath = Path.GetDirectoryName(project.FullName);
            if (projectPath == null) return selectedConnection;

            var path = Path.GetDirectoryName(project.FullName);
            if (!ConfigFileExists(project)) return null;

            XmlDocument doc = new XmlDocument();
            doc.Load(path + "\\CRMDeveloperExtensions.config");

            XmlNodeList connections = doc.GetElementsByTagName("Connection");
            if (connections.Count == 0) return selectedConnection;

            //Get the selected Connection info
            foreach (XmlNode node in connections)
            {
                XmlNode selectedNode = node["Selected"];
                if (selectedNode == null) continue;

                bool selected;
                bool isBool = Boolean.TryParse(selectedNode.InnerText, out selected);
                if (!isBool) continue;
                if (!selected) continue;

                XmlNode connectionStringNode = node["ConnectionString"];
                if (connectionStringNode == null) continue;

                selectedConnection.ConnectionString = DecodeString(connectionStringNode.InnerText);

                XmlNode orgIdNode = node["OrgId"];
                if (orgIdNode == null) continue;

                selectedConnection.OrgId = orgIdNode.InnerText;

                XmlNode vesionNode = node["Version"];
                if (vesionNode == null) continue;

                selectedConnection.Version = vesionNode.InnerText;

                break;
            }

            return selectedConnection;
        }