void SetApplicationIcon()
        {
            string         iconPath = this.applicationIconTextBox.Text;
            string         newIconId;
            ResourceScript rc;

            if (iconPath.Trim() == "")
            {
                return;
            }
            if (iconResourceScriptPath != null)
            {
                rc        = new ResourceScript(iconResourceScriptPath);
                newIconId = foundIconEntry != null ? foundIconEntry.ResourceID : DEFAULT_ICON_ID;
                rc.Save(iconResourceScriptPath);
            }
            else
            {
                iconResourceScriptPath = AddResourceScriptToProject(base.Project, DEFAULT_RC_NAME);
                rc        = new ResourceScript();
                newIconId = DEFAULT_ICON_ID;
            }
            rc.SetIcon(newIconId, iconPath);
            rc.Save(iconResourceScriptPath);
        }
        /// <summary>
        /// Gets the icon file location from the rc files added to project.
        /// Searches all project items of type "ResourceCompile" and returns the resource of type ICON with the lowest ID.
        /// </summary>
        /// <returns>path to the icon file or null if the icon wasn't specified</returns>
        string GetApplicationIconPathFromResourceScripts()
        {
            foundIconEntry         = null;
            iconResourceScriptPath = null;
            IEnumerable <ProjectItem> resourceScripts = base.Project.Items.Where(
                item => item is FileProjectItem && ((FileProjectItem)item).BuildAction == "ResourceCompile");

            // search in all resource scripts, but due to limitation in resource compiler, only one of them can contain icons
            foreach (ProjectItem item in resourceScripts)
            {
                ResourceScript rc = new ResourceScript(item.FileName);
                if (rc.Icons.Count == 0)
                {
                    continue;
                }
                if (foundIconEntry == null || rc.Icons.First().ResourceID.CompareTo(foundIconEntry.ResourceID) < 0)
                {
                    foundIconEntry         = rc.Icons.First();
                    iconResourceScriptPath = item.FileName;
                }
            }

            //when no icon was found, then select the resource script where icon definition may be created
            if (iconResourceScriptPath == null && resourceScripts.Any())
            {
                iconResourceScriptPath = resourceScripts.First().FileName;
            }

            return(foundIconEntry != null ? foundIconEntry.Data : null);
        }