Ejemplo n.º 1
0
        private void UpdateSelectedProperty(bool setSelectedItemNull)
        {
            if (selectedProperty != null)
            {
                selectedProperty.DefaultValue = txtDefaultValue.Text;
                selectedProperty.Description  = txtDescription.Text;
                selectedProperty.Name         = txtPropertyName.Text;

                switch (selectedProperty.SearchType)
                {
                case PropertySearchType.DirectorySearch:
                    DirectorySearch dirSearch = (DirectorySearch)selectedProperty.propSearch[PropertySearchType.DirectorySearch];
                    dirSearch.DirectoryPath = (string)dgrPropertySearch[1, 0].Value;
                    dirSearch.Depth         = (string)dgrPropertySearch[1, 1].Value;
                    break;

                case PropertySearchType.FileSearch:
                    FileSearch fileSearch = (FileSearch)selectedProperty.propSearch[PropertySearchType.FileSearch];
                    fileSearch.DirectoryPath = (string)dgrPropertySearch[1, 0].Value;
                    fileSearch.Depth         = (string)dgrPropertySearch[1, 1].Value;
                    fileSearch.FileName      = (string)dgrPropertySearch[1, 2].Value;
                    break;

                case PropertySearchType.INISearch:
                    INISearch iniSearch = (INISearch)selectedProperty.propSearch[PropertySearchType.INISearch];
                    iniSearch.Name    = (string)dgrPropertySearch[1, 0].Value;
                    iniSearch.Section = (string)dgrPropertySearch[1, 1].Value;
                    iniSearch.Key     = (string)dgrPropertySearch[1, 2].Value;
                    break;

                case PropertySearchType.RegistrySearch:
                    RegistrySearch regSearch = (RegistrySearch)selectedProperty.propSearch[PropertySearchType.RegistrySearch];
                    regSearch.Root = (string)dgrPropertySearch[1, 0].Value;
                    regSearch.Key  = (string)dgrPropertySearch[1, 1].Value;
                    regSearch.Name = (string)dgrPropertySearch[1, 2].Value;
                    break;
                }

                if (UserDefinedPropertyChanged != null)
                {
                    UserDefinedPropertyChanged(null, null);
                }
            }

            if (setSelectedItemNull)
            {
                selectedProperty = null;
            }
        }
Ejemplo n.º 2
0
        private void cmbSearchType_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (selectedProperty != null)
            {
                selectedProperty.SearchType = (PropertySearchType)Enum.Parse(typeof(PropertySearchType), (string)cmbSearchType.SelectedItem);
                dgrPropertySearch.Rows.Clear();
                switch (selectedProperty.SearchType)
                {
                case PropertySearchType.DirectorySearch:
                    DirectorySearch dirSearch = (DirectorySearch)selectedProperty.propSearch[PropertySearchType.DirectorySearch];
                    dgrPropertySearch.Rows.Add(dirSearch.DirectoryPathText, dirSearch.DirectoryPath);
                    dgrPropertySearch.Rows.Add(dirSearch.DepthText, dirSearch.Depth);
                    dgrPropertySearch.Tag = dirSearch;
                    break;

                case PropertySearchType.FileSearch:
                    FileSearch fileSearch = (FileSearch)selectedProperty.propSearch[PropertySearchType.FileSearch];
                    dgrPropertySearch.Rows.Add(fileSearch.DirectoryPathText, fileSearch.DirectoryPath);
                    dgrPropertySearch.Rows.Add(fileSearch.DepthText, fileSearch.Depth);
                    dgrPropertySearch.Rows.Add(fileSearch.FileNameText, fileSearch.FileName);
                    dgrPropertySearch.Tag = fileSearch;
                    break;

                case PropertySearchType.INISearch:
                    INISearch iniSearch = (INISearch)selectedProperty.propSearch[PropertySearchType.INISearch];
                    dgrPropertySearch.Rows.Add(iniSearch.NameText, iniSearch.Name);
                    dgrPropertySearch.Rows.Add(iniSearch.SectionText, iniSearch.Section);
                    dgrPropertySearch.Rows.Add(iniSearch.KeyText, iniSearch.Key);
                    dgrPropertySearch.Tag = iniSearch;
                    break;

                case PropertySearchType.None: dgrPropertySearch.Tag = null; break;

                case PropertySearchType.RegistrySearch:
                    RegistrySearch regSearch = (RegistrySearch)selectedProperty.propSearch[PropertySearchType.RegistrySearch];
                    dgrPropertySearch.Rows.Add(regSearch.RootText, regSearch.Root);
                    dgrPropertySearch.Rows.Add(regSearch.KeyText, regSearch.Key);
                    dgrPropertySearch.Rows.Add(regSearch.NameText, regSearch.Name);
                    dgrPropertySearch.Tag = regSearch;
                    break;
                }
            }
        }
Ejemplo n.º 3
0
        void INvnControl.Build()
        {
            foreach (WindowsProperty property in propertyItems.Items)
            {
                Wix.Property msiProperty = new Wix.Property();
                msiProperty.Id    = property.Name;
                msiProperty.Value = property.DefaultValue;

                // PROPERTY SEARCH
                switch (property.SearchType)
                {
                case PropertySearchType.DirectorySearch:
                    Wix.DirectorySearch wixDirSearch = new Wix.DirectorySearch();
                    wixDirSearch.Id = Common.GetId();
                    DirectorySearch dirSearch = (DirectorySearch)property.propSearch[PropertySearchType.DirectorySearch];
                    wixDirSearch.Path           = dirSearch.DirectoryPath;
                    wixDirSearch.Depth          = dirSearch.Depth;
                    msiProperty.DirectorySearch = new Wix.DirectorySearch[] { wixDirSearch };
                    break;

                case PropertySearchType.FileSearch:
                    Wix.DirectorySearch wixFlDirSearch = new Wix.DirectorySearch();
                    wixFlDirSearch.Id = Common.GetId();
                    FileSearch flDirSearch = (FileSearch)property.propSearch[PropertySearchType.FileSearch];
                    wixFlDirSearch.Path  = flDirSearch.DirectoryPath;
                    wixFlDirSearch.Depth = flDirSearch.Depth;
                    Wix.FileSearch wixFileSearch = new Wix.FileSearch();
                    wixFileSearch.Id            = Common.GetId();
                    wixFileSearch.Name          = flDirSearch.FileName;
                    wixFlDirSearch.Item         = wixFileSearch;
                    msiProperty.DirectorySearch = new Wix.DirectorySearch[] { wixFlDirSearch };
                    break;

                case PropertySearchType.INISearch:
                    Wix.IniFileSearch wixIniSearch = new Wix.IniFileSearch();
                    wixIniSearch.Id = Common.GetId();
                    INISearch iniSearch = (INISearch)property.propSearch[PropertySearchType.INISearch];
                    wixIniSearch.Name         = iniSearch.Name;
                    wixIniSearch.Section      = iniSearch.Section;
                    wixIniSearch.Key          = iniSearch.Key;
                    msiProperty.IniFileSearch = new Wix.IniFileSearch[] { wixIniSearch };
                    break;

                case PropertySearchType.None: break;

                case PropertySearchType.RegistrySearch:
                    Wix.RegistrySearch wixRegSearch = new Wix.RegistrySearch();
                    wixRegSearch.Id = Common.GetId();
                    RegistrySearch regSearch = (RegistrySearch)property.propSearch[PropertySearchType.RegistrySearch];
                    wixRegSearch.Root          = (Wix.RegistrySearchRoot)Enum.Parse(typeof(Wix.RegistrySearchRoot), regSearch.Root);
                    wixRegSearch.Key           = regSearch.Key;
                    wixRegSearch.Name          = regSearch.Name;
                    msiProperty.RegistrySearch = new Wix.RegistrySearch[] { wixRegSearch };
                    break;
                }

                if (MsiBuilder.PropertyElements.ContainsKey(msiProperty.Id))
                {
                    MsiBuilder.PropertyElements[msiProperty.Id] = msiProperty;
                }
                else
                {
                    MsiBuilder.PropertyElements.Add(msiProperty.Id, msiProperty);
                }
            }
        }