Example #1
0
        void LoadSettings()
        {
            Util.BootstrapperPackage[] packages = Util.BootstrapperPackage.GetBootstrappers();
            DataTable tablePackages             = new DataTable("Packages");

            tablePackages.Columns.Add("ProductCode", typeof(string));
            tablePackages.Columns.Add("DisplayName", typeof(string));
            tablePackages.Columns.Add("Checked", typeof(bool));
            tablePackages.DefaultView.Sort = "DisplayName ASC";

            ItemGroup itemGroup = config.ItemGroupBootstrapperPackages;

            foreach (Util.BootstrapperPackage package in packages)
            {
                string ProductCode = package.ProductCode;
                string DisplayName = package.DisplayName;
                bool   Checked     = false;
                if (itemGroup.ContainsKey(ProductCode))
                {
                    BootstrapperPackageItem item = itemGroup[ProductCode] as BootstrapperPackageItem;
                    if (item != null && item.Install)
                    {
                        Checked = true;
                    }
                }

                tablePackages.Rows.Add(ProductCode, DisplayName, Checked);
            }

            foreach (DataRowView view in tablePackages.DefaultView)
            {
                Util.BootstrapperPackage package = new Util.BootstrapperPackage(
                    view["ProductCode"] as string,
                    view["DisplayName"] as string,
                    (bool)view["Checked"]);

                chkListBoxBootstrappers.Items.Add(package, package.Checked);
            }

            CsProject.PropertyCollection properties = config.PropertyItems;
            chkBootstrapperEnabled.Checked = properties.BootstrapperEnabled;

            switch (properties.BootstrapperComponentsLocation)
            {
            case BootstrappersLocations.Relative:
                radioComponentsLocationRelative.Checked = true;
                break;

            case BootstrappersLocations.Absolute:
                radioComponentsLocationAbsolute.Checked = true;
                break;

            default:
                radioComponentsLocationDefault.Checked = true;
                break;
            }

            cmbBootstrapperComponentsUrl.Text = properties.BootstrapperComponentsUrl;
        }
Example #2
0
        void SaveSettings()
        {
            for (int i = 0; i < chkListBoxBootstrappers.Items.Count; i++)
            {
                Util.BootstrapperPackage package = chkListBoxBootstrappers.Items[i] as Util.BootstrapperPackage;
                if (package == null)
                {
                    continue;
                }

                bool isChecked = chkListBoxBootstrappers.GetItemChecked(i);

                ItemGroup itemGroup = config.ItemGroupBootstrapperPackages;

                BootstrapperPackageItem item = null;
                if (itemGroup.ContainsKey(package.ProductCode))
                {
                    item = itemGroup[package.ProductCode] as BootstrapperPackageItem;
                }
                else
                {
                    item = new BootstrapperPackageItem(package.ProductCode);
                    itemGroup.Add(item);
                }

                item.Install = isChecked;
            }

            CsProject.PropertyCollection properties = config.PropertyItems;
            properties.BootstrapperEnabled = chkBootstrapperEnabled.Checked;

            if (radioComponentsLocationRelative.Checked)
            {
                properties.BootstrapperComponentsLocation = CsProject.BootstrappersLocations.Relative;
            }
            else if (radioComponentsLocationAbsolute.Checked)
            {
                properties.BootstrapperComponentsLocation = CsProject.BootstrappersLocations.Absolute;
            }
            else
            {
                properties.BootstrapperComponentsLocation = CsProject.BootstrappersLocations.Default;
            }
            properties.BootstrapperComponentsUrl = cmbBootstrapperComponentsUrl.Text;
        }
        public void RefreshPublishFiles()
        {
            string basePath = Path.GetDirectoryName(this.FileName);
            string distPath = pubSettings.DistributionPath;

            if (!Directory.Exists(distPath))
            {
                return;
            }

            List <string> fileNames = new List <string>();

            getFileNames(fileNames, distPath);

            ItemGroup itemGroupContents     = items.Groups["Content"];
            ItemGroup itemGroupPublishFiles = items.Groups["PublishFile"];

            foreach (string file in fileNames)
            {
                string fullName = Path.GetFullPath(file);
                string include  = Sense.Utils.IO.Path.GetRelativePath(basePath, fullName);
                string link     = Sense.Utils.IO.Path.GetRelativePath(distPath, fullName);
                if (!itemGroupContents.ContainsKey(fullName))
                {
                    ContentItem item = new ContentItem(basePath, include, link);
                    item.CopyToOutputDirectory = "PreserveNewest";
                    itemGroupContents.Add(item);
                }
                if (!itemGroupPublishFiles.ContainsKey(link))
                {
                    PublishFileItem item = new PublishFileItem(link);
                    item.Visible      = false;
                    item.Group        = "";
                    item.TargetPath   = "";
                    item.PublishState = PublishState.Include;
                    item.IncludeHash  = true;
                    item.FileType     = "File";
                    itemGroupPublishFiles.Add(item);
                }
            }
            List <string> removes = new List <string>();

            foreach (string fullName in itemGroupContents.GetKeys())
            {
                if (!fileNames.Contains(fullName))
                {
                    removes.Add(fullName);
                }
            }
            foreach (string fullName in removes)
            {
                if (itemGroupContents.ContainsKey(fullName))
                {
                    itemGroupContents.Remove(fullName);
                }
            }
            removes.Clear();
            foreach (string item in itemGroupPublishFiles.GetKeys())
            {
                bool found = false;
                foreach (ContentItem contentItem in itemGroupContents)
                {
                    string include = null;
                    if (contentItem.NeedLinkNode(basePath))
                    {
                        include = contentItem.Link;
                    }
                    else
                    {
                        include = contentItem.GetInclude(basePath);
                    }

                    if (item == include)
                    {
                        found = true;
                        break;
                    }
                }

                if (found)
                {
                    continue;
                }
                removes.Add(item);
            }
            foreach (string item in removes)
            {
                if (itemGroupPublishFiles.ContainsKey(item))
                {
                    itemGroupPublishFiles.Remove(item);
                }
            }
        }