Exemplo n.º 1
0
        private void removeSelectedScriptsFromTheLeftFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //TODO: finish real delete!
            if (lstFiles.SelectedItems.Count == 0)
            {
                return;
            }

            this.Cursor = Cursors.WaitCursor;
            StringBuilder sb = new StringBuilder("Are you sure you want to remove the follow file(s)?\r\n\r\n");;

            for (int i = 0; i < lstFiles.SelectedItems.Count; i++)
            {
                sb.Append("  " + ((FileCompareResults)lstFiles.SelectedItems[i].Tag).LeftScriptRow.FileName + "\r\n");
            }


            if (DialogResult.No == MessageBox.Show(sb.ToString(), "Delete Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
            {
                this.Cursor = Cursors.Default;
                return;
            }


            //Get list of rows to remove then remove them.
            SqlSyncBuildData.ScriptRow[] rows = new SqlSyncBuildData.ScriptRow[lstFiles.SelectedItems.Count];
            for (int i = 0; i < lstFiles.SelectedItems.Count; i++)
            {
                FileCompareResults results = (FileCompareResults)lstFiles.SelectedItems[i].Tag;
                rows[i] = results.LeftScriptRow;
            }
            //TODO: Check for delete from an SBX file
            if (!SqlBuildFileHelper.RemoveScriptFilesFromBuild(ref this.buildData, Path.Combine(this.leftTempFilePath, XmlFileNames.MainProjectFile), this.leftZipFilePath, rows, true))
            {
                MessageBox.Show("Unable to remove file from list. Please try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }


            if (lstFiles.SelectedItems.Count > 0)
            {
                this.refreshProjectList = true;
            }


            btnCompare_Click(null, EventArgs.Empty);

            this.Cursor = Cursors.Default;
        }