Exemplo n.º 1
0
        private void BindIconControls()
        {
            string imagesFolder = Path.Combine(
                Application.StartupPath,
                "Images"
                );

            string[] pngFiles = Directory.GetFiles(
                imagesFolder,
                "*.png",
                SearchOption.AllDirectories
                );

            IEnumerable <string> iconFiles = pngFiles.Where(IsIcon);

            foreach (string iconFile in iconFiles)
            {
                string file = iconFile;

                BindingWrapper <string> iconItemWrapper = new BindingWrapper <string>(
                    iconFile, s => Path.GetFileName(file)
                    );

                cmbNodeIcon.Items.Add(iconItemWrapper);

                string iconName = Path.GetFileNameWithoutExtension(file);

                if (this._node.ImageKey == iconName)
                {
                    cmbNodeIcon.SelectedItem  = iconItemWrapper;
                    picIconNode.ImageLocation = iconFile;
                }
            }
        }
Exemplo n.º 2
0
        private void UpdateServerInstanceList()
        {
            cmbServerInstance.Enabled = false;

            ClearServerInstanceList();

            ConnectionGroupInfo group = SelectedGroup;

            if (group != null)
            {
                foreach (InstanceInfo instanceInfo in group.Connections)
                {
                    if (!string.IsNullOrEmpty(instanceInfo.Name))
                    {
                        BindingWrapper <InstanceInfo> instanceWrapper = new BindingWrapper <InstanceInfo>(
                            instanceInfo, i => i.Name
                            );

                        cmbServerInstance.Items.Add(instanceWrapper);
                    }
                }

                if (cmbServerInstance.Items.Count > 0)
                {
                    cmbServerInstance.SelectedIndex = 0;

                    UpdateTemplateList();
                }
            }

            cmbServerInstance.Enabled = true;
        }
        private void InitializeBindings()
        {
            // set data source type bindings
            List <BindingWrapper <ConnectionType> > connectionTypes = this._model.ConnectionTypes;

            this._lastConnections = ReadLastConnections(connectionTypes.Select(bw => bw.Item).ToList());

            // retrieve last connection group
            LastConnectionRow lastConnectionRow =
                this._storage.LastConnectionTable.GetLastConnection(Environment.MachineName);

            ConnectionInfo lastConnection = null;

            if (lastConnectionRow != null)
            {
                lastConnection = this._lastConnections.Values
                                 .FirstOrDefault(lc => lastConnectionRow.LastConnectionProtocolId == lc.ConnectionId);
            }

            this.bsConnectionType.DataSource = connectionTypes;
            this.bsConnectionType.DataMember = "Item";

            this.cmbDataBaseType.DataSource = bsConnectionType.DataSource;

            // select data source type used in previous session
            if (this.cmbDataBaseType.Items.Count > 0)
            {
                this.cmbDataBaseType.SelectedItem = 0;
                if (lastConnection != null)
                {
                    BindingWrapper <ConnectionType> selItem = connectionTypes.FirstOrDefault(
                        ct => ct.Item.Id == lastConnection.ConnectionType);

                    if (selItem != null)
                    {
                        this.cmbDataBaseType.SelectedItem = selItem;
                    }
                }

                // set module type bindings
                BindModuleType(lastConnection);
            }

            // load external templates paths from sqlite db
            cmbPathToFile.Items.Clear();
            List <TemplateRow> externalTemplates = this._storage.TemplateDirectory.GetExternalTemplates();

            foreach (TemplateRow externalTemplate in externalTemplates)
            {
                string path = Path.Combine(externalTemplate.Directory, externalTemplate.Id);
                cmbPathToFile.Items.Add(path);
            }

            UpdateConnections(lastConnection);
            BindTemplate(lastConnection);

            UpdateControlsState();
        }
Exemplo n.º 4
0
        private void cmbNodeIcon_SelectedIndexChanged(object sender, EventArgs e)
        {
            BindingWrapper <string> selectedIcon = cmbNodeIcon.SelectedItem as BindingWrapper <string>;

            if (selectedIcon != null)
            {
                picIconNode.ImageLocation = selectedIcon.Item;
            }
        }
        private void UpdateConnections(ConnectionInfo restoreConnection)
        {
            cmbConnection.Items.Clear();

            BindingWrapper <ConnectionType> typeWrapper = this.cmbDataBaseType.SelectedItem as BindingWrapper <ConnectionType>;

            if (typeWrapper != null)
            {
                ConnectionType selectedConnection = typeWrapper.Item;

                LoadConnectionGroups(selectedConnection, this._connectionsManager);
                LoadConnectionInstances(selectedConnection, this._connectionsManager);

                UpdateConnectionSelection(restoreConnection);
            }
        }
        private void BindTemplate(ConnectionInfo restoreConnection)
        {
            BindingWrapper <ModuleType> selectedModule = cmbModuleTypes.SelectedValue as BindingWrapper <ModuleType>;

            if (selectedModule != null)
            {
                List <Template> templates = this._templates.Value;

                this.bsTemplateFileSetting.DataSource = templates.Where(
                    x => x.Type == selectedModule.Item.Id).ToList();

                cmbTemplate.Enabled = (cmbModuleTypes.SelectedItem != null);

                optOpenTemplateFromFile.Checked = false;
                optSelectExistTemplate.Checked  = true;
                cmbPathToFile.ResetText();
                if (restoreConnection != null)
                {
                    if (this.cmbTemplate.Items.Count > 0)
                    {
                        this.cmbTemplate.SelectedIndex = 0;
                    }

                    string templateDir = restoreConnection.TemplateDir;
                    if (!string.IsNullOrEmpty(templateDir) && Path.IsPathRooted(templateDir))
                    {
                        optOpenTemplateFromFile.Checked = true;
                        optSelectExistTemplate.Checked  = false;

                        cmbPathToFile.Text = Path.Combine(templateDir, restoreConnection.TemplateFile);
                    }
                    else
                    {
                        foreach (Template template in this.cmbTemplate.Items.OfType <Template>())
                        {
                            if (template != null && template.Id == restoreConnection.TemplateId)
                            {
                                this.cmbTemplate.SelectedItem = template;
                                break;
                            }
                        }
                    }
                }
            }
        }
        private void BindModuleType(ConnectionInfo restoreConnection)
        {
            this.cmbModuleTypes.Enabled = false;

            BindingWrapper <ConnectionType> cnnWrapper = (BindingWrapper <ConnectionType>) this.cmbDataBaseType.SelectedItem;

            if (cnnWrapper != null)
            {
                ConnectionType cnnType = cnnWrapper.Item;

                List <BindingWrapper <ModuleType> > moduleTypes = this._model.GetModuleTypes(cnnType);

                if (moduleTypes.Count > 0)
                {
                    this.bsModuleType.DataSource   = moduleTypes;
                    this.bsModuleType.DataMember   = "Item";
                    this.cmbModuleTypes.DataSource = this.bsModuleType.DataSource;
                    this.cmbModuleTypes.Enabled    = true;

                    // select module type used in previous session
                    if (restoreConnection != null)
                    {
                        bool     selected = false;
                        Template template = this._templates.Value.FirstOrDefault(t => restoreConnection.TemplateId == t.Id);
                        if (template != null)
                        {
                            BindingWrapper <ModuleType> lastModule = moduleTypes.FirstOrDefault(
                                m => m.Item.Id == template.Type);

                            if (lastModule != null)
                            {
                                this.cmbModuleTypes.SelectedItem = lastModule;
                                selected = true;
                            }
                        }

                        if (!selected)
                        {
                            this.cmbModuleTypes.SelectedIndex = 0;
                        }
                    }
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Save keybindings.
        /// </summary>
        public void Save()
        {
            List <Binding> overrides = new List <Binding>();

            foreach (InputActionMap map in controls.asset.actionMaps)
            {
                foreach (InputBinding binding in map.bindings)
                {
                    if (!string.IsNullOrEmpty(binding.overridePath))
                    {
                        overrides.Add(new Binding(binding.id.ToString(), binding.overridePath));
                    }
                }
            }

            BindingWrapper toSave = new BindingWrapper(overrides);

            PlayerPrefs.SetString("Controls", JsonUtility.ToJson(toSave));
        }
Exemplo n.º 9
0
        private void UpdateTemplateList()
        {
            cmbTemplate.Enabled = false;
            ClearTemplateList();

            ConnectionGroupInfo group    = SelectedGroup;
            InstanceInfo        instance = SelectedInstance;

            if (group != null && instance != null)
            {
                List <TemplateRow> templates = this._templateManager
                                               .GetTemplates(group.Name, instance.Name, instance.DbType)
                                               .Where(row => !Path.IsPathRooted(row.Directory))
                                               .ToList();

                foreach (TemplateRow templateRow in templates)
                {
                    string displayName = templateRow.Id;

                    Template template = this._templates.Find(t => t.Id == templateRow.Name);

                    if (template != null)
                    {
                        displayName = string.Format("{0} ({1})", template.Display, templateRow.Name);
                    }

                    BindingWrapper <TemplateRow> templateWrapper = new BindingWrapper <TemplateRow>(
                        templateRow, row => displayName
                        );

                    cmbTemplate.Items.Add(templateWrapper);
                }

                if (cmbTemplate.Items.Count > 0)
                {
                    cmbTemplate.SelectedIndex = 0;

                    UpdateLoginList();
                }
            }

            cmbTemplate.Enabled = true;
        }
Exemplo n.º 10
0
        public IContextUpdatCycleBreaker SetBinding <TView>(TView view, IBinding binding) where TView : class
        {
            var typedBinding = binding as IBinding <TView, TContext>;

            if (typedBinding == null)
            {
                throw new InvalidOperationException($"Invalid binding type. Expected: {typeof(IBinding<TView, TContext>)}");
            }

            var wrapper = new BindingWrapper <TView>(view, typedBinding);

            AddBinding(wrapper);

            UpdateViewValue(wrapper);

            return(typedBinding.CanUpdateContext
                 ? new ContextUpdatCycleBreaker <TView>(typedBinding, this)
                 : null);
        }
Exemplo n.º 11
0
        private void UpdateConnectionGroupList()
        {
            BindingWrapper <ConnectionType> connectionWrapper = cmbDataType.SelectedItem as BindingWrapper <ConnectionType>;

            if (connectionWrapper != null)
            {
                cmbConnectionGroup.Enabled = false;
                ClearConnectionGroupList();

                string protocol = connectionWrapper.Item.Id;
                List <ConnectionGroupInfo> groups = this._connectionsManager.GetAllGroups(protocol)
                                                    .Where(groupInfo =>
                {
                    List <InstanceInfo> instances = groupInfo.Connections;

                    if (!instances.IsNullOrEmpty() && instances.TrueForAll(i => !i.IsDynamicConnection))
                    {
                        return(true);
                    }

                    return(false);
                }).ToList();

                foreach (ConnectionGroupInfo groupInfo in groups)
                {
                    BindingWrapper <ConnectionGroupInfo> groupWrapper = new BindingWrapper <ConnectionGroupInfo>(
                        groupInfo, g => g.Name);

                    cmbConnectionGroup.Items.Add(groupWrapper);
                }

                cmbConnectionGroup.Enabled = true;

                if (groups.Count > 0)
                {
                    cmbConnectionGroup.SelectedIndex = 0;

                    UpdateServerInstanceList();
                }
            }
        }
Exemplo n.º 12
0
        protected override bool UpdateBinding()
        {
            _valueAssigned = false;
            IDataDescriptor sourceDd;

            if (!Evaluate(out sourceDd))
            {
                return(false);
            }
            BindingWrapper bindingWrapper = sourceDd.Value as BindingWrapper;

            if (bindingWrapper == null || bindingWrapper.Binding == null)
            {
                return(false);
            }
            IBinding binding = bindingWrapper.Binding.CopyAndRetarget(_targetDataDescriptor);

            // When the binding is copied, this instance is not needed any more
            _valueAssigned = true;
            Dispose();
            return(true);
        }
Exemplo n.º 13
0
        private void UpdateLoginList()
        {
            cmbLogin.Enabled = false;

            ClearLoginList();

            ConnectionGroupInfo group    = SelectedGroup;
            InstanceInfo        instance = SelectedInstance;
            TemplateRow         template = SelectedTemplate;

            if (group != null && instance != null && template != null)
            {
                List <LoginRow> logins = this._loginManager.GetLogins(
                    template.Name,
                    group.Name,
                    instance.Name,
                    instance.DbType
                    );

                if (logins.Count > 0)
                {
                    foreach (LoginRow loginRow in logins)
                    {
                        BindingWrapper <LoginRow> loginWrapper = new BindingWrapper <LoginRow>(
                            loginRow,
                            DisplayLogin
                            );

                        cmbLogin.Items.Add(loginWrapper);
                    }

                    cmbLogin.SelectedIndex = 0;
                }
            }

            cmbLogin.Enabled = true;
        }
Exemplo n.º 14
0
        protected void RunSelectConnectionDialog(MsSqlAuditorModel model)
        {
            BindingWrapper <ConnectionType> connectionWrapper = cmbDataBaseType.SelectedItem as BindingWrapper <ConnectionType>;

            if (connectionWrapper != null)
            {
                ConnectionType connectionType = connectionWrapper.Item;
                QuerySource    querySource;

                if (!Enum.TryParse(connectionType.Id, true, out querySource))
                {
                    return;
                }

                IConnectionStringDialog dialog = ConnectionStringDialogFactory.CreateDialog(
                    querySource,
                    model
                    );

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    DbConnectionStringBuilder builder = GetConnectionStringBuilder(
                        querySource,
                        dialog.ConnectionString,
                        dialog.IsOdbc
                        );

                    InstanceInfo newInstance = InstanceInfoResolver.ResolveInstance(
                        builder,
                        dialog.IsOdbc,
                        querySource
                        );

                    SelectInstance(newInstance);
                }
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Load keybindings.
        /// </summary>
        public void Load()
        {
            BindingWrapper load = JsonUtility.FromJson <BindingWrapper>(PlayerPrefs.GetString("Controls"));

            if (load == null || load.overrides.Count <= 0)
            {
                return;
            }

            foreach (InputActionMap map in controls.asset.actionMaps)
            {
                UnityEngine.InputSystem.Utilities.ReadOnlyArray <InputBinding> bindings = map.bindings;
                for (int i = 0; i < bindings.Count; i++)
                {
                    Binding overrideBinding = load.overrides.SingleOrDefault(x => x.id == bindings[i].id.ToString());
                    if (overrideBinding != null)
                    {
                        map.ApplyBindingOverride(i, new InputBinding {
                            overridePath = overrideBinding.path
                        });
                    }
                }
            }
        }
Exemplo n.º 16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HtmlConverter"/> class.
 /// </summary>
 /// <param name="bindingWrapper">The binding wrapper.</param>
 public HtmlConverter(BindingWrapper bindingWrapper)
     : base(bindingWrapper)
 {
 }
		private void UpdateServerInstanceList()
		{
			cmbServerInstance.Enabled = false;

			ClearServerInstanceList();

			ConnectionGroupInfo group = SelectedGroup;

			if (group != null)
			{
				foreach (InstanceInfo instanceInfo in group.Connections)
				{
					if (!string.IsNullOrEmpty(instanceInfo.Name))
					{
						BindingWrapper<InstanceInfo> instanceWrapper = new BindingWrapper<InstanceInfo>(
							instanceInfo, i => i.Name
						);

						cmbServerInstance.Items.Add(instanceWrapper);
					}
				}

				if (cmbServerInstance.Items.Count > 0)
				{
					cmbServerInstance.SelectedIndex = 0;

					UpdateTemplateList();
				}
			}

			cmbServerInstance.Enabled = true;
		}
		private void UpdateConnectionGroupList()
		{
			BindingWrapper<ConnectionType> connectionWrapper = cmbDataType.SelectedItem as BindingWrapper<ConnectionType>;

			if (connectionWrapper != null)
			{
				cmbConnectionGroup.Enabled = false;
				ClearConnectionGroupList();

				string protocol = connectionWrapper.Item.Id;
				List<ConnectionGroupInfo> groups = this._connectionsManager.GetAllGroups(protocol)
					.Where(groupInfo =>
					{
						List<InstanceInfo> instances = groupInfo.Connections;

						if (!instances.IsNullOrEmpty() && instances.TrueForAll(i => !i.IsDynamicConnection))
						{
							return true;
						}

						return false;
					}).ToList();

				foreach (ConnectionGroupInfo groupInfo in groups)
				{
					BindingWrapper<ConnectionGroupInfo> groupWrapper = new BindingWrapper<ConnectionGroupInfo>(
						groupInfo, g => g.Name);

					cmbConnectionGroup.Items.Add(groupWrapper);
				}

				cmbConnectionGroup.Enabled = true;

				if (groups.Count > 0)
				{
					cmbConnectionGroup.SelectedIndex = 0;

					UpdateServerInstanceList();
				}
			}
		}
		private void UpdateTemplateList()
		{
			cmbTemplate.Enabled = false;
			ClearTemplateList();

			ConnectionGroupInfo group    = SelectedGroup;
			InstanceInfo        instance = SelectedInstance;

			if (group != null && instance != null)
			{
				List<TemplateRow> templates = this._templateManager
					.GetTemplates(group.Name, instance.Name, instance.DbType)
					.Where(row => !Path.IsPathRooted(row.Directory))
					.ToList();

				foreach (TemplateRow templateRow in templates)
				{
					string displayName = templateRow.Id;

					Template template = this._templates.Find(t => t.Id == templateRow.Name);

					if (template != null)
					{
						displayName = string.Format("{0} ({1})", template.Display, templateRow.Name);
					}

					BindingWrapper<TemplateRow> templateWrapper = new BindingWrapper<TemplateRow>(
						templateRow, row => displayName
					);

					cmbTemplate.Items.Add(templateWrapper);
				}

				if (cmbTemplate.Items.Count > 0)
				{
					cmbTemplate.SelectedIndex = 0;

					UpdateLoginList();
				}
			}

			cmbTemplate.Enabled = true;
		}
Exemplo n.º 20
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            BindingWrapper <string> iconItem = cmbNodeIcon.SelectedItem as BindingWrapper <string>;

            if (iconItem == null)
            {
                return;
            }

            string           iconFileName = Path.GetFileNameWithoutExtension(iconItem.Item);
            TemplateNodeInfo nodeInfo     = this._nodeDefinition.TemplateNode;
            string           nodeName     = nodeInfo.Title;

            if (string.IsNullOrEmpty(nodeName))
            {
                nodeName = GetNodeName();
            }

            string additionalText = this._node.Text.Length > nodeName.Length
                                ? this._node.Text.Substring(nodeName.Length)
                                : "";

            this._node.Text             = txtNodeName.Text + additionalText;
            this._node.ImageKey         = iconFileName;
            this._node.SelectedImageKey = iconFileName;

            if (this._nodeDefinition.NodeAvailable)
            {
                this._node.ForeColor = panelColor.BackColor;
            }

            this._nodeDefinition.NodeActivated = !chkDeactivateNode.Checked;

            if (this._nodeDefinition.TemplateNode.Childs.Count > 0)
            {
                bool disableChild = chkDeactivateNode.Checked;
                UpdateChildNodes(this._node, disableChild);
            }

            string nodeUiName = this.txtNodeName.Text;

            TemplateNodeLocaleInfo locale = nodeInfo.Locales.FirstOrDefault(
                l => l.Language == this._model.Settings.InterfaceLanguage
                );

            if (locale != null)
            {
                if (locale.Text == nodeUiName)
                {
                    nodeUiName = string.Empty;
                }
            }

            nodeInfo.FontColor  = this.panelColor.BackColor.Name;
            nodeInfo.UIcon      = iconFileName;
            nodeInfo.Title      = nodeUiName;
            nodeInfo.IsDisabled = this.chkDeactivateNode.Checked;

            this._userSettingsManager.SaveUserSettings(
                new UserSettingsRow {
                TemplateNodeId = nodeInfo.TemplateNodeId.GetValueOrDefault(),
                NodeEnabled    = !this.chkDeactivateNode.Checked,
                NodeFontColor  = this.panelColor.BackColor.Name,
                NodeUIIcon     = iconFileName,
                NodeUIName     = nodeUiName
            }
                );

            this._model.GetVaultProcessor(this._nodeDefinition.Connection)
            .CurrentStorage.Save(nodeInfo);
        }
		private void UpdateLoginList()
		{
			cmbLogin.Enabled = false;

			ClearLoginList();

			ConnectionGroupInfo group    = SelectedGroup;
			InstanceInfo        instance = SelectedInstance;
			TemplateRow         template = SelectedTemplate;

			if (group != null && instance != null && template != null)
			{
				List<LoginRow> logins = this._loginManager.GetLogins(
					template.Name,
					group.Name,
					instance.Name,
					instance.DbType
				);

				if (logins.Count > 0)
				{
					foreach (LoginRow loginRow in logins)
					{
						BindingWrapper<LoginRow> loginWrapper = new BindingWrapper<LoginRow>(
							loginRow,
							DisplayLogin
						);

						cmbLogin.Items.Add(loginWrapper);
					}

					cmbLogin.SelectedIndex = 0;
				}
			}

			cmbLogin.Enabled = true;
		}
        private void populateGroups(ObservableCollection<BindingWrapper<Group>> wrappers, Group[] groups)
        {
            if (groups != null && groups.Length > 0)
            {
                foreach (Group group in groups)
                {
                    BindingWrapper<Group> wrapper = new BindingWrapper<Group>();
                    wrapper.Content = group;
                    wrapper.Tag = IsUserOwnerOfGroup(group) ? Visibility.Visible : Visibility.Collapsed;

                    wrappers.Add(wrapper);
                }

                MyGroupsListBox.ItemsSource = wrappers;
                MyGroupsListBox.Visibility = Visibility.Visible;
                SearchResultsTextBlock.Text = string.Format(ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.Resources.Strings.MyGroupControlGroups, groups.Length);
            }
            else
                SearchResultsTextBlock.Text = ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.Resources.Strings.MyGroupControlZeroGroups;
        }
Exemplo n.º 23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConverterBaseClass"/> class.
 /// </summary>
 /// <param name="tools">The tools.</param>
 protected ConverterBaseClass(BindingWrapper tools)
 {
     Tools = tools;
 }
		private void BindIconControls()
		{
			string imagesFolder = Path.Combine(
				Application.StartupPath,
				"Images"
			);

			string[] pngFiles = Directory.GetFiles(
				imagesFolder,
				"*.png",
				SearchOption.AllDirectories
			);

			IEnumerable<string> iconFiles = pngFiles.Where(IsIcon);

			foreach (string iconFile in iconFiles)
			{
				string file = iconFile;

				BindingWrapper<string> iconItemWrapper = new BindingWrapper<string>(
					iconFile, s => Path.GetFileName(file)
				);

				cmbNodeIcon.Items.Add(iconItemWrapper);

				string iconName = Path.GetFileNameWithoutExtension(file);

				if (this._node.ImageKey == iconName)
				{
					cmbNodeIcon.SelectedItem  = iconItemWrapper;
					picIconNode.ImageLocation = iconFile;
				}
			}
		}
Exemplo n.º 25
0
		public List<BindingWrapper<ModuleType>> GetModuleTypes(ConnectionType connectionType)
		{
			List<BindingWrapper<ModuleType>> moduleTypes = new List<BindingWrapper<ModuleType>>();

			if (connectionType != null && connectionType.ModuleTypes != null && connectionType.ModuleTypes.Any())
			{
				foreach (ModuleType moduleType in connectionType.ModuleTypes)
				{
					BindingWrapper<ModuleType> wrapper = new BindingWrapper<ModuleType>(
						moduleType,
						m =>
						{
							i18n localeItem = m.Locales.FirstOrDefault(
								l => l.Language == Settings.InterfaceLanguage
							);

							string displayName = localeItem != null
								? localeItem.Text
								: m.Id;

							return displayName.RemoveWhitespaces();
						}
					);

					moduleTypes.Add(wrapper);
				}
			}

			return moduleTypes;
		}
		private void InitializeBindings()
		{
			// retrieve connection type
			ConnectionType connectionType = null;
			InstanceInfo   firstInstance = this._connectionGroup.Connections.FirstOrDefault();

			if (firstInstance != null)
			{
				BindingWrapper<ConnectionType> typeWrapper = this._model.GetConnectionType(firstInstance.Type);

				if (typeWrapper != null)
				{
					connectionType = typeWrapper.Item;
					cmbDataBaseType.DataSource = Lists.Of(typeWrapper);
				}
			}

			Template template = null;

			if (this._connectionGroup.IsExternal)
			{
				this.optOpenTemplateFromFile.Checked = true;

				string path = Path.Combine(
					this._connectionGroup.TemplateDir,
					this._connectionGroup.TemplateFileName
				);

				this.cmbPathToFile.DataSource = Lists.Of(path);

				XmlSerializer serializer = new XmlSerializer(typeof(Template));
				XmlDocument docTemplate = new XmlDocument();

				docTemplate.Load(path);

				using (XmlNodeReader nodeReader = new XmlNodeReader(docTemplate))
				{
					using (XmlReader xmlReader = XmlReader.Create(nodeReader, XmlUtils.GetXmlReaderSettings()))
					{
						template = (Template) serializer.Deserialize(xmlReader);
					}
				}
			}
			else
			{
				this.optSelectExistTemplate.Checked = true;

				template = this._templates.Value.FirstOrDefault(t => t.Id == this._connectionGroup.TemplateId);

				if (template != null)
				{
					TemplateNodeLocaleInfo locale = template.Locales.FirstOrDefault(
						l => l.Language == Settings.InterfaceLanguage
					);

					string templateName = (locale ?? template.Locales.First()).Text;

					this.cmbTemplate.DataSource = Lists.Of(templateName.RemoveWhitespaces());
				}
			}

			if (template != null && connectionType != null)
			{
				string     templateType = template.Type;
				ModuleType moduleType   = connectionType.ModuleTypes.FirstOrDefault(
					m => m.Id == templateType
				);

				if (moduleType != null)
				{
					BindingWrapper<ModuleType> moduleWrapper = new BindingWrapper<ModuleType>(
						moduleType,
						module =>
						{
							i18n localeItem = module.Locales.FirstOrDefault(
								l => l.Language == Settings.InterfaceLanguage);

							string displayName = localeItem != null
								? localeItem.Text
								: module.Id;

							return displayName.RemoveWhitespaces();
						}
					);

					cmbModuleTypes.DataSource = Lists.Of(moduleWrapper);
				}

				FillConnections(connectionType);

				SelectCurrentGroup();

				txtGroupName.Text = this._connectionGroup.Name;
			}
		}
        private void InitializeBindings()
        {
            // retrieve connection type
            ConnectionType connectionType = null;
            InstanceInfo   firstInstance  = this._connectionGroup.Connections.FirstOrDefault();

            if (firstInstance != null)
            {
                BindingWrapper <ConnectionType> typeWrapper = this._model.GetConnectionType(firstInstance.Type);

                if (typeWrapper != null)
                {
                    connectionType             = typeWrapper.Item;
                    cmbDataBaseType.DataSource = Lists.Of(typeWrapper);
                }
            }

            Template template = null;

            if (this._connectionGroup.IsExternal)
            {
                this.optOpenTemplateFromFile.Checked = true;

                string path = Path.Combine(
                    this._connectionGroup.TemplateDir,
                    this._connectionGroup.TemplateFileName
                    );

                this.cmbPathToFile.DataSource = Lists.Of(path);

                XmlSerializer serializer  = new XmlSerializer(typeof(Template));
                XmlDocument   docTemplate = new XmlDocument();

                docTemplate.Load(path);

                using (XmlNodeReader nodeReader = new XmlNodeReader(docTemplate))
                {
                    using (XmlReader xmlReader = XmlReader.Create(nodeReader, XmlUtils.GetXmlReaderSettings()))
                    {
                        template = (Template)serializer.Deserialize(xmlReader);
                    }
                }
            }
            else
            {
                this.optSelectExistTemplate.Checked = true;

                template = this._templates.Value.FirstOrDefault(t => t.Id == this._connectionGroup.TemplateId);

                if (template != null)
                {
                    TemplateNodeLocaleInfo locale = template.Locales.FirstOrDefault(
                        l => l.Language == Settings.InterfaceLanguage
                        );

                    string templateName = (locale ?? template.Locales.First()).Text;

                    this.cmbTemplate.DataSource = Lists.Of(templateName.RemoveWhitespaces());
                }
            }

            if (template != null && connectionType != null)
            {
                string     templateType = template.Type;
                ModuleType moduleType   = connectionType.ModuleTypes.FirstOrDefault(
                    m => m.Id == templateType
                    );

                if (moduleType != null)
                {
                    BindingWrapper <ModuleType> moduleWrapper = new BindingWrapper <ModuleType>(
                        moduleType,
                        module =>
                    {
                        i18n localeItem = module.Locales.FirstOrDefault(
                            l => l.Language == Settings.InterfaceLanguage);

                        string displayName = localeItem != null
                                                                ? localeItem.Text
                                                                : module.Id;

                        return(displayName.RemoveWhitespaces());
                    }
                        );

                    cmbModuleTypes.DataSource = Lists.Of(moduleWrapper);
                }

                FillConnections(connectionType);

                SelectCurrentGroup();

                txtGroupName.Text = this._connectionGroup.Name;
            }
        }