private void PublishUnmappedResource(LinkerData existing)
        {
            if (this.webresources.SelectedNode != null && this.webresources.SelectedNode.Tag != null)
            {
                // tag is only set internally so we should be ok without an error check here :P
                Guid webresourceId = new Guid(this.webresources.SelectedNode.Tag.ToString());

                // get rid of anything that's mapped with this sourcefile/webresourceid and add a clean one to avoid corruption on the mapping file
                existing.Mappings.RemoveAll(a =>
                    {
                        return a.WebResourceId == webresourceId
                            // check both the id and sourcepath because we now have to support re-linking
                            || a.SourceFilePath.Equals(this.UnmappedFile.FriendlyFilePath, StringComparison.InvariantCultureIgnoreCase);
                    });

                // add a clean mapping for this webresource and file
                existing.Mappings.Add(new LinkerDataItem
                    {
                        WebResourceId = webresourceId,
                        SourceFilePath = this.UnmappedFile.FriendlyFilePath
                    });

                Publish(new Guid[] { webresourceId }, new string[] { this.UnmappedFile.FilePath });

                this.PublishedFiles.Add(this.UnmappedFile);
                this.UnmappedFile = null;

                this.currentmapping.Text = "";
            }
        }
        public void Initialize()
        {
            this.UnmappedFile = null;
            this.PublishedFiles = new List<SelectedFile>();

            LoadImages();

            if (this.ShowConnectionWindow)
            {
                this.Show();

                ShowConnectionDialog();
            }
            else { ShowExistingWebResources(); }

            // when this method is called while relink is set it wont attempt to publish anything else other than the 1st file inside selectedfiles array
            if (this.Relink) { this.MarkAsUnmapped(this.SelectedFiles[0]); }
        }
        private void MarkAsUnmapped(SelectedFile selectedFile)
        {
            this.UnmappedFile = selectedFile;

            this.currentmapping.Text = string.Format("Please map and publish: {0}", selectedFile.FriendlyFilePath);
            ToggleControls(true);

            this.Show(); // need to show the ui so the user can pick the web resource to map with
        }