/// <summary>
        /// Save settings from the this control to the given destination.
        /// </summary>
        /// <returns>True if all settings have been saved, false otherwise</returns>
        public bool SaveTo(IAndroidProjectProperties destination)
        {
            // Select lib references to add/remove
            var libNames      = new HashSet <string>(destination.ReferencedLibraryNames.Select(x => x.ToLowerInvariant()));
            var nodesToAdd    = new List <LibraryNode>();
            var nodesToRemove = new List <LibraryNode>();

            foreach (var libNode in additionalLibrariesControl.Libraries)
            {
                var key = libNode.DllName.ToLowerInvariant();
                if (libNode.Checked)
                {
                    if (!libNames.Contains(key))
                    {
                        nodesToAdd.Add(libNode);
                    }
                }
                else if (!libNode.Checked)
                {
                    if (libNames.Contains(key))
                    {
                        nodesToRemove.Add(libNode);
                    }
                }
            }

            // Agree to licenses
            if (nodesToAdd.Any(x => x.License != null))
            {
                // Must accept to agreement(s)
                if (!nodesToAdd.AcceptToAll())
                {
                    return(false);
                }
            }

            // Do actual save
            destination.PackageName              = PackageName;
            destination.ApkFilename              = ApkFilename;
            destination.TargetFrameworkVersion   = TargetFrameworkVersion;
            destination.TargetSdkAndroidVersion  = TargetSdkAndroidVersion;
            destination.ApkCertificatePath       = ApkCertificatePath;
            destination.ApkCertificateThumbprint = ApkCertificateThumbprint;
            destination.GenerateWcfProxy         = cbGenerateWcfProxy.Checked;
            foreach (var node in nodesToRemove)
            {
                destination.RemoveReferencedLibrary(node.DllName);
            }
            foreach (var node in nodesToAdd)
            {
                destination.AddReferencedLibrary(node.DllName);
            }

            return(true);
        }
        /// <summary>
        /// Load settings from the given source into this control.
        /// </summary>
        public void LoadFrom(IAndroidProjectProperties source)
        {
            PackageName                = source.PackageName;
            ApkFilename                = source.ApkFilename;
            TargetFrameworkVersion     = source.TargetFrameworkVersion;
            TargetSdkAndroidVersion    = source.TargetSdkAndroidVersion;
            ApkCertificatePath         = source.ApkCertificatePath;
            ApkCertificateThumbprint   = source.ApkCertificateThumbprint;
            cbGenerateWcfProxy.Checked = source.GenerateWcfProxy;

            var libNames = new HashSet <string>(source.ReferencedLibraryNames.Select(x => x.ToLowerInvariant()));

            foreach (var libNode in additionalLibrariesControl.Libraries)
            {
                var key = libNode.DllName.ToLowerInvariant();
                if (libNames.Contains(key))
                {
                    libNode.Checked = false;
                }
            }
        }
        private void SetVisibleRows(IAndroidProjectProperties source)
        {
            ShowRow(tbApkFilename, source.ApkOutputs);
            ShowRow(tbPackageName, source.ApkOutputs);
            ShowRow(tbCertificate, source.ApkOutputs);
            ShowRow(cbGenerateSetNextInstructionCode, source.ApkOutputs);
            ShowRow(labelSetNextInstructionHelp, source.ApkOutputs);
            ShowRow(cbEnableCompilerCache, source.ApkOutputs);
            ShowRow(labelCompilerCacheHelp, source.ApkOutputs);

            // TODO: not sure about the other properties.
        }
        /// <summary>
        /// Save settings from the this control to the given destination.
        /// </summary>
        /// <returns>True if all settings have been saved, false otherwise</returns>
        public bool SaveTo(IAndroidProjectProperties destination)
        {
            // Select lib references to add/remove
            var libNames = new HashSet<string>(destination.ReferencedLibraryNames.Select(x => x.ToLowerInvariant()));
            var nodesToAdd = new List<LibraryNode>();
            var nodesToRemove = new List<LibraryNode>();
            foreach (var libNode in additionalLibrariesControl.Libraries)
            {
                var key = libNode.DllName.ToLowerInvariant();
                if (libNode.Checked)
                {
                    if (!libNames.Contains(key))
                        nodesToAdd.Add(libNode);
                }
                else if (!libNode.Checked)
                {
                    if (libNames.Contains(key))
                        nodesToRemove.Add(libNode);
                }
            }

            // Agree to licenses
            if (nodesToAdd.Any(x => x.License != null))
            {
                // Must accept to agreement(s)
                if (!nodesToAdd.AcceptToAll())
                    return false;
            }

            // Do actual save
            destination.PackageName = PackageName;
            destination.ApkFilename = ApkFilename;
            destination.TargetFrameworkVersion = TargetFrameworkVersion;
            destination.TargetSdkAndroidVersion = TargetSdkAndroidVersion;
            destination.ApkCertificatePath = ApkCertificatePath;
            destination.ApkCertificateThumbprint = ApkCertificateThumbprint;
            destination.GenerateWcfProxy = cbGenerateWcfProxy.Checked;
            destination.AssemblyName = AssemblyName;
            destination.RootNamespace = RootNamespace;
            destination.GenerateSetNextInstructionCode = cbGenerateSetNextInstructionCode.Checked;
            destination.EnableCompilerCache= cbEnableCompilerCache.Checked;

            foreach (var node in nodesToRemove) destination.RemoveReferencedLibrary(node.DllName);
            foreach (var node in nodesToAdd) destination.AddReferencedLibrary(node.DllName);

            return true;
        }
        /// <summary>
        /// Load settings from the given source into this control.
        /// </summary>
        public void LoadFrom(IAndroidProjectProperties source)
        {
            PackageName = source.PackageName;
            ApkFilename = source.ApkFilename;
            TargetFrameworkVersion = source.TargetFrameworkVersion;
            TargetSdkAndroidVersion = source.TargetSdkAndroidVersion;
            ApkCertificatePath = source.ApkCertificatePath;
            ApkCertificateThumbprint = source.ApkCertificateThumbprint;
            cbGenerateWcfProxy.Checked = source.GenerateWcfProxy;
            cbGenerateSetNextInstructionCode.Checked = source.GenerateSetNextInstructionCode;
            cbEnableCompilerCache.Checked = source.EnableCompilerCache;
            AssemblyName = source.AssemblyName;
            RootNamespace = source.RootNamespace;

            var libNames = new HashSet<string>(source.ReferencedLibraryNames.Select(x => x.ToLowerInvariant()));
            foreach (var libNode in additionalLibrariesControl.Libraries)
            {
                var key = libNode.DllName.ToLowerInvariant();
                if (libNames.Contains(key))
                {
                    libNode.Checked = true;
                }
            }

            SetVisibleRows(source);
        }
        /// <summary>
        /// Load settings from the given source into this control.
        /// </summary>
        public void LoadFrom(IAndroidProjectProperties source)
        {
            PackageName = source.PackageName;
            ApkFilename = source.ApkFilename;
            TargetFrameworkVersion = source.TargetFrameworkVersion;
            TargetSdkAndroidVersion = source.TargetSdkAndroidVersion;
            ApkCertificatePath = source.ApkCertificatePath;
            ApkCertificateThumbprint = source.ApkCertificateThumbprint;
            cbGenerateWcfProxy.Checked = source.GenerateWcfProxy;

            var libNames = new HashSet<string>(source.ReferencedLibraryNames.Select(x => x.ToLowerInvariant()));
            foreach (var libNode in additionalLibrariesControl.Libraries)
            {
                var key = libNode.DllName.ToLowerInvariant();
                if (libNames.Contains(key))
                {
                    libNode.Checked = false;
                }
            }
        }